// Copyright 2003-2004 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. namespace Apache.Avalon.Composition.Data { using System; /// Avalon Development Team /// /// $Revision: 1.2 $ $Date: 2004/02/28 22:15:36 $ /// [Serializable] public class ResourceDirective { /// Group identifier. private System.String m_group; /// The name identifier. private System.String m_name; /// The type identifier. private System.String m_type; /// Creation of a new resource directive. /// the artifact group /// /// the artifact name /// public ResourceDirective(System.String group, System.String name):this(group, name, "assembly") { } /// Creation of a new resource directive. /// the artifact group /// /// the artifact name /// /// the artifact version /// public ResourceDirective(System.String group, System.String name, System.String type) { if ((System.Object) group == null) { throw new System.NullReferenceException("group"); } if ((System.Object) name == null) { throw new System.NullReferenceException("name"); } if ((System.Object) type == null) { throw new System.NullReferenceException("type"); } m_group = group; m_name = name; m_type = type; } /// Return the composite identifier. /// the identifier /// public virtual System.String Id { get { return m_group + ":" + m_name; } } /// Return the artifact name /// the artifact name /// public virtual System.String Name { get { return m_name; } } /// Return the group of the artifact. /// the artifact group /// public virtual System.String Group { get { return m_group; } } /// Return the type of the artifact. /// the artifact type /// public virtual System.String Type { get { return m_type; } } /// Creation of a new resource directive. /// the artifact id /// /// the artifact version /// public static ResourceDirective CreateResourceDirective(System.String id) { return CreateResourceDirective(id, "assembly"); } /// Creation of a new resource directive. /// the artifact id /// /// the artifact version /// public static ResourceDirective CreateResourceDirective(System.String id, System.String type) { if ((System.Object) id == null) { throw new System.NullReferenceException("id"); } if ((System.Object) type == null) { throw new System.NullReferenceException("type"); } System.String group = null; System.String name = null; int n = id.IndexOf(":"); if (id.IndexOf(":") > 0) { group = id.Substring(0, (n) - (0)); name = id.Substring(n + 1, (id.Length) - (n + 1)); } else { group = id; name = id; } return new ResourceDirective(group, name, type); } } }