Ejemplo n.º 1
0
 private static string ValidatePropertyPath(System.Type viewType, string inputProperty)
 {
     System.Type type      = viewType;
     string[]    strArray1 = inputProperty.Split('.');
     string[]    strArray2 = new string[strArray1.Length];
     for (int index = 0; index < strArray1.Length; ++index)
     {
         PropertyInfo propertyInfo = (PropertyInfo)null;
         if (type != (System.Type)null)
         {
             ViReflectionCache.GetTypeProperties(type).TryGetValue(strArray1[index].ToLower(), out propertyInfo);
         }
         if (propertyInfo != (PropertyInfo)null)
         {
             type             = propertyInfo.PropertyType;
             strArray2[index] = VimClient.MakeCamelCase(propertyInfo.Name);
         }
         else
         {
             strArray2[index] = VimClient.MakeCamelCase(strArray1[index]);
             type             = (System.Type)null;
         }
     }
     return(string.Join(".", strArray2));
 }
        private static void SetPropertyTypesAndFixCasing(DynamicPropertyFilterSpecGenerator.PropertyDefinition[] propertyPathList, string startingType)
        {
            Type type = DynamicPropertyFilterSpecGenerator.GetType(startingType);
            int  i    = 0;

            while (i < propertyPathList.Length)
            {
                DynamicPropertyFilterSpecGenerator.PropertyDefinition propertyDefinition = propertyPathList[i];
                if (propertyDefinition.Name == "*")
                {
                    break;
                }
                Dictionary <string, PropertyInfo> arg_3F_0 = ViReflectionCache.GetTypeProperties(type);
                PropertyInfo propertyInfo = null;
                arg_3F_0.TryGetValue(propertyDefinition.Name.ToLower(), out propertyInfo);
                if (propertyInfo == null)
                {
                    throw new ArgumentException(string.Format(Resources.PropertyDoesNotExist, propertyDefinition.Name));
                }
                propertyDefinition.Name = VimClient.MakeCamelCase(propertyInfo.Name);
                if (propertyInfo.PropertyType == typeof(ManagedObjectReference) || propertyInfo.PropertyType == typeof(ManagedObjectReference[]))
                {
                    type = DynamicPropertyFilterSpecGenerator.GetType(string.Format("{0}_LinkedView", type.Name));
                    ViReflectionCache.GetTypeProperties(type).TryGetValue(propertyDefinition.Name.ToLower(), out propertyInfo);
                    if (propertyDefinition.VimType != DynamicPropertyFilterSpecGenerator.VimType.ManagedObject)
                    {
                        propertyDefinition.VimType = DynamicPropertyFilterSpecGenerator.VimType.ManagedObject;
                        goto IL_169;
                    }
                    if (!DynamicPropertyFilterSpecGenerator.GetType(DynamicPropertyFilterSpecGenerator.FixTypeName(propertyInfo.PropertyType.Name)).IsAssignableFrom(DynamicPropertyFilterSpecGenerator.GetType(propertyDefinition.ObjectType)))
                    {
                        throw new ArgumentException(string.Format(Resources.WrongPropertyType, propertyDefinition.Name, propertyInfo.PropertyType.Name));
                    }
                    type = DynamicPropertyFilterSpecGenerator.GetType(propertyDefinition.ObjectType);
                }
                else
                {
                    if (propertyDefinition.VimType == DynamicPropertyFilterSpecGenerator.VimType.ManagedObject)
                    {
                        throw new ArgumentException(string.Format(Resources.SpecifiedDataObjectType, propertyDefinition.Name));
                    }
                    propertyDefinition.VimType = DynamicPropertyFilterSpecGenerator.VimType.DataObject;
                    goto IL_169;
                }
IL_18D:
                i++;
                continue;
IL_169:
                type = DynamicPropertyFilterSpecGenerator.GetType(propertyInfo.PropertyType.Name);
                propertyDefinition.ObjectType = propertyInfo.PropertyType.Name;
                goto IL_18D;
            }
        }
Ejemplo n.º 3
0
        internal static string MakePropertyCamelCase(string property)
        {
            string str = property;

            if (!string.IsNullOrEmpty(property))
            {
                string[] strArray1 = property.Split('.');
                string[] strArray2 = new string[strArray1.Length];
                for (int index = 0; index < strArray1.Length; ++index)
                {
                    strArray2[index] = VimClient.MakeCamelCase(strArray1[index]);
                }
                str = string.Join(".", strArray2);
            }
            return(str);
        }