Ejemplo n.º 1
0
 public void UpdateViewData(params string[] properties)
 {
     PropertyCollector propertyCollector = new PropertyCollector(this._client, this._client.ServiceContent.PropertyCollector);
     PropertyFilterSpec resultPropertyFilterSpec;
     Dictionary<string, List<string>> currentAllowedPropertyPath;
     DynamicPropertyFilterSpecGenerator.Generate(this.MoRef, VimClient.MakePropertiesCamelCase(properties), out resultPropertyFilterSpec, out currentAllowedPropertyPath);
     PropertyFilterSpec[] specSet = new PropertyFilterSpec[1]
     {
 resultPropertyFilterSpec
     };
     ObjectContent[] objectContentArray = propertyCollector.RetrieveProperties(specSet);
     Dictionary<string, ObjectContent> objectContentList = new Dictionary<string, ObjectContent>();
     foreach (ObjectContent objectContent in objectContentArray)
         objectContentList.Add(objectContent.Obj.Value, objectContent);
     Dictionary<string, ViewBase> generatedManagedObjectList = new Dictionary<string, ViewBase>();
     if (properties != null)
     {
         List<string> stringList = new List<string>((IEnumerable<string>)properties);
     }
     ViewBase.SetViewData(this, (string)null, currentAllowedPropertyPath, objectContentList, generatedManagedObjectList);
 }
Ejemplo n.º 2
0
        public List <ViewBase> GetViews(IEnumerable <ManagedObjectReference> moRefs, params string[] properties)
        {
            if (moRefs == null)
            {
                throw new ArgumentNullException("moRefs");
            }
            if (this._vimService == null)
            {
                throw new InvalidOperationException(Resources.VimWebServiceNotInitialized);
            }
            if (this._serviceContent == null)
            {
                throw new InvalidOperationException(Resources.ServiceContentNotInitialized);
            }
            Dictionary <string, PropertyFilterSpec> dictionary = new Dictionary <string, PropertyFilterSpec>();

            foreach (ManagedObjectReference moRef in moRefs)
            {
                if (dictionary.ContainsKey(moRef.Type.ToLower()))
                {
                    PropertyFilterSpec propertyFilterSpec = dictionary[moRef.Type.ToLower()];
                    ObjectSpec[]       array = new List <ObjectSpec>((IEnumerable <ObjectSpec>)propertyFilterSpec.ObjectSet)
                    {
                        new ObjectSpec()
                        {
                            Obj = moRef
                        }
                    }.ToArray();
                    propertyFilterSpec.ObjectSet = array;
                }
                else
                {
                    PropertySpec propertySpec = new PropertySpec();
                    propertySpec.Type = moRef.Type;
                    if (properties != null && properties.Length != 0)
                    {
                        propertySpec.All     = new bool?(false);
                        propertySpec.PathSet = VimClient.MakePropertiesCamelCase(properties);
                    }
                    else
                    {
                        propertySpec.All = new bool?(true);
                    }
                    dictionary.Add(moRef.Type.ToLower(), new PropertyFilterSpec()
                    {
                        PropSet = new PropertySpec[1] {
                            propertySpec
                        },
                        ObjectSet = new List <ObjectSpec>()
                        {
                            new ObjectSpec()
                            {
                                Obj = moRef
                            }
                        }.ToArray()
                    });
                }
            }
            PropertyFilterSpec[] propertyFilterSpecArray = new PropertyFilterSpec[dictionary.Values.Count];
            dictionary.Values.CopyTo(propertyFilterSpecArray, 0);
            return(this.GetViews(new PropertyCollector((VimClient)this, this._serviceContent.PropertyCollector).RetrieveProperties(propertyFilterSpecArray), properties));
        }