Exemple #1
0
		internal void VerifyQualifierNames(MofSpecificationSet mof)
		{
			foreach (ClassDeclaration property in mof.ClassDeclarations.Values)
			{
				this.CheckForUnrecognizedQualifiers(property.Qualifiers);
				IEnumerator<PropertyDeclaration> enumerator = property.Properties.GetEnumerator();
				using (enumerator)
				{
					while (enumerator.MoveNext())
					{
						PropertyDeclaration propertyDeclaration = enumerator.Current;
						this.CheckForUnrecognizedQualifiers(propertyDeclaration.Qualifiers);
					}
				}
			}
		}
Exemple #2
0
		internal void AddToSchema(Schema schema, MofSpecificationSet mof, XElement resources)
		{
			this.VerifyQualifierNames(mof);
			this.VerifyClassNames(mof);
			HashSet<MofProduction> mofProductions = new HashSet<MofProduction>();
			foreach (XElement xElement in resources.Elements())
			{
				mof.GetClosureOfClass(mofProductions, xElement.GetUniqueElement("http://schemas.microsoft.com/powershell-web-services/2010/09", "Class").Value);
			}
			List<ResourceType> resourceTypes = new List<ResourceType>();
			List<ResourceType> resourceTypes1 = new List<ResourceType>();
			HashSet<MofProduction> mofProductions1 = mofProductions;
			foreach (MofProduction mofProduction in mofProductions1.Where<MofProduction>((MofProduction item) => item is ClassDeclaration))
			{
				SchemaLoader.CreateResourceType(mofProduction as ClassDeclaration, mofProductions, schema, resourceTypes, resourceTypes1);
			}
			foreach (MofProduction mofProduction1 in mofProductions)
			{
				ClassDeclaration classDeclaration = mofProduction1 as ClassDeclaration;
				if (classDeclaration == null)
				{
					continue;
				}
				SchemaLoader.ClassCategory category = classDeclaration.GetCategory();
				switch (category)
				{
					case SchemaLoader.ClassCategory.Complex:
					{
						SchemaLoader.PopulateComplexType(schema, resourceTypes, classDeclaration);
						continue;
					}
					case SchemaLoader.ClassCategory.Entity:
					{
						SchemaLoader.PopulateEntityType(schema, resourceTypes, resourceTypes1, classDeclaration);
						continue;
					}
					case SchemaLoader.ClassCategory.Association:
					{
						SchemaLoader.PopulateAssociationType(schema, resourceTypes1, classDeclaration);
						continue;
					}
				}
				throw new NotImplementedException(string.Concat("class category ", classDeclaration.GetCategory()));
			}
			foreach (XElement xElement1 in resources.Elements())
			{
				string value = xElement1.GetUniqueElement("http://schemas.microsoft.com/powershell-web-services/2010/09", "RelativeUrl").Value;
				string str = xElement1.GetUniqueElement("http://schemas.microsoft.com/powershell-web-services/2010/09", "Class").Value;
				ResourceType resourceType = resourceTypes1.Find((ResourceType item) => item.FullName == SchemaLoader.TransformCimNameToCsdl(str, true));
				if (resourceType != null)
				{
					schema.AddResourceSet(value, resourceType);
				}
				else
				{
					object[] csdl = new object[1];
					csdl[0] = SchemaLoader.TransformCimNameToCsdl(str, true);
					throw new ArgumentException(ExceptionHelpers.GetExceptionMessage(Resources.EntityTypeResourceNotFound, csdl));
				}
			}
			foreach (MofProduction mofProduction2 in mofProductions)
			{
				if (mofProduction2 as ClassDeclaration == null || (mofProduction2 as ClassDeclaration).GetCategory () != SchemaLoader.ClassCategory.Entity)
				{
					continue;
				}
				SchemaLoader.AddReferenceProperties(schema, resourceTypes1, mofProduction2 as ClassDeclaration, mofProductions);
			}
			foreach (Schema.AssociationType associationType in schema.AssociationTypes.Values)
			{
				associationType.CreateWcfType(schema.ResourceSets);
			}
		}
Exemple #3
0
		internal void VerifyClassNames(MofSpecificationSet mof)
		{
			foreach (ClassDeclaration value in mof.ClassDeclarations.Values)
			{
				if (!value.Name.Identifier.Contains<char>('\u005F') && !string.IsNullOrEmpty(value.Name.Schema))
				{
					continue;
				}
				object[] fullName = new object[1];
				fullName[0] = value.Name.FullName;
				throw new MetadataException(ExceptionHelpers.GetExceptionMessage(Resources.UseCimClassName, fullName));
			}
		}