Exemplo n.º 1
0
        internal Segment<byte>? GetCell(PropertyKey key)
        {
            var colDef = _columnDefs.FirstOrDefault(d => d.Tag.Key == key);
            if (colDef == null)
                return null;

            if (!ColumnExists(colDef.CebIndex))
                return null;

            var type = colDef.Tag.Type;
            Segment<byte> data;
            var offset = colDef.Offset + (_rowIndex * _offsets.Bm);
            if (!type.IsVariableLength() && type.GetLength() <= 8)
            {
                var length = colDef.Tag.Type.GetLength();
                data = _rowData.Derive(offset, length);
            }
            else
            {
                var hnid = BitConverter.ToUInt32(_rowData.Array, _rowData.Offset + offset);
                if ((hnid & 0x1f) == 0)
                {
                    data = _heap[hnid];
                }
                else
                {
                    var subnode = _node.FindSubnode(hnid);
                    var subBlock = subnode.GetDataBlock();
                    data = subBlock.Data;
                }
            }

            return data;
        }
        public void ConstructorWithString(string formatId, int propertyId)
        {
            PropertyKey pk = new PropertyKey(formatId, propertyId);

            Assert.Equal<Guid>(new Guid(formatId), pk.FormatId);
            Assert.Equal<int>(propertyId, pk.PropertyId);
        }
        public virtual int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue)
        {
            Command command = ParentCommandManager.Get((CommandId)commandId);
            if (command == null)
            {
                return NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue);
            }

            try
            {
                newValue = new PropVariant();
                command.GetPropVariant(key, currentValue, ref newValue);

                if (newValue.IsNull())
                {
                    Trace.Fail("Didn't property update property for " + PropertyKeys.GetName(key) + " on command " + ((CommandId)commandId).ToString());

                    newValue = PropVariant.FromObject(currentValue.PropVariant.Value);
                }
            }
            catch (Exception ex)
            {
                Trace.Fail("Exception in UpdateProperty for " + PropertyKeys.GetName(key) + " on command " + commandId + ": " + ex);
                newValue = PropVariant.FromObject(currentValue.PropVariant.Value);
            }

            return HRESULT.S_OK;
        }
        public EntityHierarchyEnumerator(EntitySystem EntitySystem, ViewModelContext selectedEntitiesContext)
        {
            isSelectedProperty = new PropertyKey<bool>("IsSelected", typeof(EntityHierarchyEnumerator), new StaticDefaultValueMetadata(false) { PropertyUpdateCallback = IsSelectedChanged });

            this.EntitySystem = EntitySystem;
            this.selectedEntitiesContext = selectedEntitiesContext;
        }
        protected object GetOverride(ref PropertyKey key, object defaultValue)
        {
            PropVariant propVariant;
            if (_overrides.TryGetValue(key, out propVariant))
                return propVariant.Value;

            return defaultValue;
        }
Exemplo n.º 6
0
 public static bool IsStringPropertyKey(PropertyKey key)
 {
     return (key == PropertyKeys.Label ||
             key == PropertyKeys.LabelDescription ||
             key == PropertyKeys.Keytip ||
             key == PropertyKeys.TooltipTitle ||
             key == PropertyKeys.TooltipDescription);
 }
 public ShellPropertyDescription GetPropertyDescription(PropertyKey key)
 {
     if (!propsDictionary.ContainsKey(key))
     {
         propsDictionary.Add(key, new ShellPropertyDescription(key));
     }
     return propsDictionary[key];
 }
        public void ConstructorWithGuid(string formatIdString, int propertyId)
        {
            Guid formatId = new Guid(formatIdString);
            PropertyKey pk = new PropertyKey(formatId, propertyId);

            Assert.Equal<Guid>(formatId, pk.FormatId);
            Assert.Equal<int>(propertyId, pk.PropertyId);
        }
 public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value)
 {
     if (key == PropertyKeys.ContextAvailable)
     {
         value.SetUInt((uint)ContextAvailability);
     }
     else
         base.GetPropVariant(key, currentValue, ref value);
 }
Exemplo n.º 10
0
 public Property FindProperty(PropertyKey key)
 {
   Type type = FindType(key);
   Property member = type.FindProperty(key);
   if (member == null)
   {
     member = type.AddProperty(key);
   }
   return member;
 }
 private void UpdateInvalidationStateAndNotifyIfDifferent(ref PropertyKey key, IComparable overrideValue, IComparableDelegate currentValueDelegate)// where T : IComparable
 {
     // Only invalidate if we're actually making a change.
     // Unnecessary invalidations hurt perf as well as cause ribbon bugs.
     if (overrideValue.CompareTo(currentValueDelegate()) != 0)
     {
         UpdateInvalidationState(key, InvalidationState.Pending);
         OnStateChanged(EventArgs.Empty);
     }
 }
        public void ToStringReturnsExpectedString()
        {
            Guid guid = new Guid("00000000-1111-2222-3333-000000000000");
            int property = 1234;

            PropertyKey key = new PropertyKey(guid, property);

            Assert.Equal<string>(
                "{" + guid.ToString() + "}, " + property.ToString(),
                key.ToString());
        }
        public void HasAssessor_PropertyInfo()
        {
            var propertyInfo = typeof(SimpleClass).GetProperty("Id");
            var propertyKey = new PropertyKey(propertyInfo);
            var assessor = CreatePropertyAssessor(propertyKey);
            _cache.TryAdd(propertyKey, assessor);

            propertyInfo = typeof(SimpleClass).GetProperty("Id");
            var result = PropertyAssessorCache.HasAssessor(propertyInfo);

            Assert.IsTrue(result);
        }
        public void HasAssessor_DeclaringType_And_PropertyName()
        {
            var declaringType = typeof(SimpleClass);
            var propertyName = "Id";
            var propertyKey = new PropertyKey(declaringType, propertyName);
            var assessor = CreatePropertyAssessor(propertyKey);
            _cache.TryAdd(propertyKey, assessor);

            var result = PropertyAssessorCache.HasAssessor(typeof(SimpleClass), "Id");

            Assert.IsTrue(result);
        }
        protected int RemoveOverride(ref PropertyKey key, IComparableDelegate currentValueDelegate)
        {
            PropVariant overrideValue;
            if (_overrides.TryGetValue(key, out overrideValue))
            {
                _overrides.Remove(key);
                UpdateInvalidationStateAndNotifyIfDifferent(ref key, (IComparable)overrideValue.Value, currentValueDelegate);
                return HRESULT.S_OK;
            }

            return HRESULT.S_FALSE;
        }
        public virtual int CancelOverride(ref PropertyKey key)
        {
            if (key == PropertyKeys.Enabled)
            {
                return RemoveOverride(ref key, () => Enabled);
            }
            if (key == PropertyKeys.ContextAvailable)
            {
                return RemoveOverride(ref key, () => (uint)ContextAvailability);
            }

            return HRESULT.E_INVALIDARG;
        }
        public void Dispatch(PropertyKey key, ExecuteEventHandlerArgs args)
        {
            ExecuteWithArgsDelegate executeWithArgsDelegate = commands[key] as ExecuteWithArgsDelegate;

            if (executeWithArgsDelegate != null)
            {
                executeWithArgsDelegate(args);
                return;
            }

            CommandId commandId = (CommandId)commands[key];
            Command command = CommandManager.Get(commandId);
            command.PerformExecuteWithArgs(args);
        }
Exemplo n.º 18
0
        internal Segment<byte> Get(PropertyKey key)
        {
            var prop = _bTree.Find((ushort)key);
            if (prop == null)
                return null;

            if (prop.Type.IsVariableLength())
            {
                if ((prop.Hnid & 0x1f) == 0)
                    return _heap[prop.Hnid];
                return _node.FindSubnode(prop.Hnid).GetDataBlock().Data;
            }

            if (prop.Type.GetLength() <= 4)
                return BitConverter.GetBytes(prop.Hnid);

            return _heap[prop.Hnid];
        }
        public void GetOrAdd_PropertyInfo_WhenIsAlreadyInCache()
        {
            var propertyInfo = typeof(SimpleClass).GetProperty("Id");
            var created = false;
            var propertyKey = new PropertyKey(propertyInfo);

            _cache.TryAdd(propertyKey, CreatePropertyAssessor(propertyKey));

            propertyInfo = typeof(SimpleClass).GetProperty("Id");
            var assessor = PropertyAssessorCache.GetOrAdd(propertyInfo, propertyKeyForCreation =>
            {
                created = true;
                return CreatePropertyAssessor(propertyKeyForCreation);
            });

            propertyInfo = typeof(SimpleClass).GetProperty("Id");
            Assert.IsTrue(_cache.ContainsKey(new PropertyKey(propertyInfo)));
            Assert.IsFalse(created);
        }
        public virtual int OverrideProperty(ref PropertyKey key, PropVariantRef overrideValue)
        {
            if (key == PropertyKeys.Enabled)
            {
                bool currentValue = Enabled;
                _overrides[key] = overrideValue.PropVariant;
                UpdateInvalidationStateAndNotifyIfDifferent(ref key, Convert.ToBoolean(overrideValue.PropVariant.Value, CultureInfo.InvariantCulture), () => currentValue);
                return HRESULT.S_OK;
            }
            else if (key == PropertyKeys.ContextAvailable)
            {
                uint currentValue = (uint)ContextAvailability;
                _overrides[key] = overrideValue.PropVariant;
                UpdateInvalidationStateAndNotifyIfDifferent(ref key, Convert.ToUInt32(overrideValue.PropVariant.Value, CultureInfo.InvariantCulture), () => currentValue);
                return HRESULT.S_OK;
            }

            return HRESULT.E_INVALIDARG;
        }
Exemplo n.º 21
0
            private void Visit(
                ApiParameterDescriptionContext bindingContext,
                BindingSource ambientSource,
                string containerName)
            {
                var source = bindingContext.BindingSource;

                if (source != null && source.IsGreedy)
                {
                    // We have a definite answer for this model. This is a greedy source like
                    // [FromBody] so there's no need to consider properties.
                    Context.Results.Add(CreateResult(bindingContext, source, containerName));
                    return;
                }

                var modelMetadata = bindingContext.ModelMetadata;

                // For any property which is a leaf node, we don't want to keep traversing:
                //
                //  1)  Collections - while it's possible to have binder attributes on the inside of a collection,
                //      it hardly seems useful, and would result in some very weird binding.
                //
                //  2)  Simple Types - These are generally part of the .net framework - primitives, or types which have a
                //      type converter from string.
                //
                //  3)  Types with no properties. Obviously nothing to explore there.
                //
                if (modelMetadata.IsEnumerableType ||
                    !modelMetadata.IsComplexType ||
                    modelMetadata.Properties.Count == 0)
                {
                    Context.Results.Add(CreateResult(bindingContext, source ?? ambientSource, containerName));
                    return;
                }

                // This will come from composite model binding - so investigate what's going on with each property.
                //
                // Ex:
                //
                //      public IActionResult PlaceOrder(OrderDTO order) {...}
                //
                //      public class OrderDTO
                //      {
                //          public int AccountId { get; set; }
                //
                //          [FromBody]
                //          public Order { get; set; }
                //      }
                //
                // This should result in two parameters:
                //
                //  AccountId - source: Any
                //  Order - source: Body
                //

                // We don't want to append the **parameter** name when building a model name.
                var newContainerName = containerName;

                if (modelMetadata.ContainerType != null)
                {
                    newContainerName = GetName(containerName, bindingContext);
                }

                for (var i = 0; i < modelMetadata.Properties.Count; i++)
                {
                    var propertyMetadata = modelMetadata.Properties[i];
                    var key         = new PropertyKey(propertyMetadata, source);
                    var bindingInfo = BindingInfo.GetBindingInfo(Enumerable.Empty <object>(), propertyMetadata);

                    var propertyContext = ApiParameterDescriptionContext.GetContext(
                        propertyMetadata,
                        bindingInfo: bindingInfo,
                        propertyName: null);

                    if (Visited.Add(key))
                    {
                        Visit(propertyContext, source ?? ambientSource, newContainerName);
                    }
                    else
                    {
                        // This is cycle, so just add a result rather than traversing.
                        Context.Results.Add(CreateResult(propertyContext, source ?? ambientSource, newContainerName));
                    }
                }
            }
Exemplo n.º 22
0
 public int OverrideProperty(uint commandId, ref PropertyKey key, PropVariantRef overrideValue)
 {
     return contentEditor.CommandManager.OverrideProperty(commandId, ref key, overrideValue);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Removes a component with the specified key.
 /// </summary>
 /// <typeparam name="T">Type of the component</typeparam>
 /// <param name="key">The key.</param>
 /// <returns><c>True</c> if the component was removed, <c>False</c> otherwise.</returns>
 public bool Remove <T>(PropertyKey <T> key)
 {
     return(Components.Remove(key));
 }
Exemplo n.º 24
0
        private static void InvalidateFont(object propertyOwner, PropertyKey <SpriteFont> propertyKey, SpriteFont propertyOldValue)
        {
            var element = (UIElement)propertyOwner;

            element.InvalidateMeasure();
        }
Exemplo n.º 25
0
        private static void InvalidateMinLines(object propertyOwner, PropertyKey <int> propertyKey, int propertyOldValue)
        {
            var editText = (EditText)propertyOwner;

            editText.OnMinLinesChanged();
        }
Exemplo n.º 26
0
 public void OnPropertyValueChanged(string pwstrDeviceId, PropertyKey key)
 {
     //Console.WriteLine($"Device with ID: {pwstrDeviceId} changed the property: {key.formatId}:{key.propertyId} to {_enumerator.GetDevice(pwstrDeviceId).Properties[key].Value.ToString()}");
 }
        /// <summary>
        /// Handles IUICommandHandler.UpdateProperty function for the supported properties
        /// </summary>
        /// <param name="key">The Property Key to update</param>
        /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param>
        /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param>
        /// <returns>Returns S_OK if successful, or an error value otherwise</returns>
        public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
        {
            if (key == RibbonProperties.AutomaticColorLabel)
            {
                if (_automaticColorLabel != null)
                {
                    newValue.SetString(_automaticColorLabel);
                }
            }
            else if (key == RibbonProperties.Color)
            {
                if (_color.HasValue)
                {
                    newValue.SetUInt((uint)ColorTranslator.ToWin32(_color.Value));
                }
            }
            else if (key == RibbonProperties.ColorType)
            {
                if (_colorType.HasValue)
                {
                    newValue.SetUInt((uint)_colorType.Value);
                }
            }
            else if (key == RibbonProperties.MoreColorsLabel)
            {
                if (_moreColorsLabel != null)
                {
                    newValue.SetString(_moreColorsLabel);
                }
            }
            else if (key == RibbonProperties.NoColorLabel)
            {
                if (_noColorLabel != null)
                {
                    newValue.SetString(_noColorLabel);
                }
            }
            else if (key == RibbonProperties.RecentColorsCategoryLabel)
            {
                if (_recentColorsCategoryLabel != null)
                {
                    newValue.SetString(_recentColorsCategoryLabel);
                }
            }
            else if (key == RibbonProperties.StandardColors)
            {
                if (_standardColors != null)
                {
                    int[]  intStandardColors  = Array.ConvertAll <Color, int>(_standardColors, new Converter <Color, int>(ColorTranslator.ToWin32));
                    uint[] uintStandardColors = Array.ConvertAll <int, uint>(intStandardColors, new Converter <int, uint>(Convert.ToUInt32));
                    newValue.SetUIntVector(uintStandardColors);
                }
            }
            else if (key == RibbonProperties.StandardColorsCategoryLabel)
            {
                if (_standardColorsCategoryLabel != null)
                {
                    newValue.SetString(_standardColorsCategoryLabel);
                }
            }
            else if (key == RibbonProperties.StandardColorsTooltips)
            {
                if (_standardColorsTooltips != null)
                {
                    newValue.SetStringVector(_standardColorsTooltips);
                }
            }
            else if (key == RibbonProperties.ThemeColors)
            {
                if (_themeColors != null)
                {
                    int[]  intThemeColors  = Array.ConvertAll <Color, int>(_themeColors, new Converter <Color, int>(ColorTranslator.ToWin32));
                    uint[] uintThemeColors = Array.ConvertAll <int, uint>(intThemeColors, new Converter <int, uint>(Convert.ToUInt32));
                    newValue.SetUIntVector(uintThemeColors);
                }
            }
            else if (key == RibbonProperties.ThemeColorsCategoryLabel)
            {
                if (_themeColorsCategoryLabel != null)
                {
                    newValue.SetString(_themeColorsCategoryLabel);
                }
            }
            else if (key == RibbonProperties.ThemeColorsTooltips)
            {
                if (_themeColorsTooltips != null)
                {
                    newValue.SetStringVector(_themeColorsTooltips);
                }
            }

            return(HRESULT.S_OK);
        }
Exemplo n.º 28
0
 internal PropertyStoreProperty(PropertyKey key, PropVariant value)
 {
     _PropertyKey = key;
     _PropValue   = value;
 }
Exemplo n.º 29
0
 /// <summary>
 /// Creates a sort column with the specified direction for the given property.
 /// </summary>
 /// <param name="propertyKey">Property key for the property that the user will sort.</param>
 /// <param name="direction">The direction in which the items are sorted.</param>
 public SortColumn(PropertyKey propertyKey, SortDirection direction)
     : this()
 {
     this.propertyKey = propertyKey;
     this.direction   = direction;
 }
Exemplo n.º 30
0
 public void SetAttribute <T>(PropertyKey <T> key, T value)
 {
     Attributes.SetObject(key, value);
 }
Exemplo n.º 31
0
 public bool TryGetAttribute <T>(PropertyKey <T> key, out T value)
 {
     return(Attributes.TryGetValue(key, out value));
 }
Exemplo n.º 32
0
 public T GetAttribute <T>(PropertyKey <T> key)
 {
     return(Attributes.Get(key));
 }
Exemplo n.º 33
0
 public bool HasAttribute(PropertyKey key)
 {
     return(Attributes.ContainsKey(key));
 }
Exemplo n.º 34
0
 /// <summary>
 /// Returns the the strongly typed value of specified property. Always returns the first appearance of the property. If it does not exist, returns <c>null</c> (<c>Nothing</c> in visual basic).
 /// </summary>
 /// <param name="propertyKey">Key to the property to obtain</param>
 /// <returns>
 /// Reference to the object that represents the strongly typed value of the property. Always returns the first appearance of the property.
 /// </returns>
 public T GetProperty <T>(PropertyKey propertyKey) => (T)GetProperty(propertyKey);
        internal static void SetWindowProperty(IntPtr hwnd, PropertyKey propkey, string value)
        {
            // Get the IPropertyStore for the given window handle
            IPropertyStore propStore = GetWindowPropertyStore(hwnd);

            // Set the value
            using (PropVariant pv = new PropVariant(value))
            {
                HResult result = propStore.SetValue(ref propkey, pv);
                if (!CoreErrorHelper.Succeeded(result))
                {
                    throw new ShellException(result);
                }
            }


            // Dispose the IPropertyStore and PropVariant
            Marshal.ReleaseComObject(propStore);
        }
Exemplo n.º 36
0
 public HResult GetPropertyDescriptionList(ref PropertyKey keyType, ref Guid riid, out IntPtr ppv)
 {
     throw new NotSupportedException();
 }
 public void OnPropertyValueChanged(string deviceId, PropertyKey propertyKey)
 {
     //Do some Work
     //fmtid & pid are changed to formatId and propertyId in the latest version NAudio
     Console.WriteLine("OnPropertyValueChanged: formatId --> {0}  propertyId --> {1}", propertyKey.formatId.ToString(), propertyKey.propertyId.ToString());
 }
Exemplo n.º 38
0
        /// <summary>
        /// Sets a group column, as specified. If no group column is specified, no grouping occurs. 
        /// </summary>
        /// <remarks>This property may not work correctly with the ExplorerBrowser control.</remarks>
        public void SetGroupColumn(PropertyKey propertyKey)
        {
            HResult hr = NativeSearchFolderItemFactory.SetGroupColumn(ref propertyKey);

            if (!CoreErrorHelper.Succeeded(hr)) { throw new ShellException(hr); }
        }
Exemplo n.º 39
0
        private static void InvalidateIsReadOnly(object propertyOwner, PropertyKey <bool> propertykey, bool propertyoldvalue)
        {
            var editText = (EditText)propertyOwner;

            editText.OnIsReadOnlyChanged();
        }
Exemplo n.º 40
0
 /// <summary>
 /// Sets a shell property for a given window
 /// </summary>
 /// <param name="propKey">The property to set</param>
 /// <param name="windowHandle">Handle to the window that the property will be set on</param>
 /// <param name="value">The value to set for the property</param>
 public static void SetWindowProperty(IntPtr windowHandle, PropertyKey propKey, string value)
 {
     TaskbarNativeMethods.SetWindowProperty(windowHandle, propKey, value);
 }
 public KeyLabel(PropertyKey key, TextBlock label)
 {
     Key   = key;
     Label = label;
 }
Exemplo n.º 42
0
 protected ShellRefProperty(
     PropertyKey propertyKey)
 {
     PropertyKey = propertyKey;
 }
        /// <inheritdoc />
        /// <summary>
        /// Gets a value that represents the value of the specified property.
        /// </summary>
        /// <param name="propertyKey">Property key to be obtained.</param>
        /// <returns>
        /// Property value
        /// </returns>
        protected override object GetValueTypedProperty(PropertyKey propertyKey)
        {
            object value = null;
            SmbiosType003Property propertyId = (SmbiosType003Property)propertyKey.PropertyId;

            switch (propertyId)
            {
                #region [0x04] - [v2.0] - [Manufacturer] - [String]
            case SmbiosType003Property.Manufacturer:
                value = Manufacturer;
                break;
                #endregion

                #region [0x05] - [v2.0] - [Type]

                #region [0x05] - [v2.0] - [Type -> Chassis Type] - [String]
            case SmbiosType003Property.ChassisType:
                value = GetEnclosureType(EnclosureType);
                break;
                #endregion

                #region [0x05] - [v2.0] - [Type -> Locked] - [String]
            case SmbiosType003Property.Locked:
                value = GetEnclosureLocked(EnclosureLocked);
                break;
                #endregion

                #endregion

                #region [0x06] - [v2.0] - [Version] - [String]
            case SmbiosType003Property.Version:
                value = Version;
                break;
                #endregion

                #region [0x07] - [v2.0] - [Serial Number] - [String]
            case SmbiosType003Property.SerialNumber:
                value = SerialNumber;
                break;
                #endregion

                #region [0x08] - [v2.0] - [Asset Tag Number] - [String]
            case SmbiosType003Property.AssetTagNumber:
                value = AssetTagNumber;
                break;
                #endregion

                #region [0x09] - [v2.1] - [Boot-up State] - [String]
            case SmbiosType003Property.BootUpState:
                if (HeaderInfo.Length >= 0x0a)
                {
                    value = GetEnclosureState(BootUpState);
                }
                break;
                #endregion

                #region [0x0a] - [v2.1] - [Power Supply State] - [String]
            case SmbiosType003Property.PowerSupplyState:
                if (HeaderInfo.Length >= 0x0b)
                {
                    value = GetEnclosureState(PowerSupplyState);
                }
                break;
                #endregion

                #region [0x0b] - [v2.1] - [Thermal State] - [String]
            case SmbiosType003Property.ThermalState:
                if (HeaderInfo.Length >= 0x0c)
                {
                    value = GetEnclosureState(ThermalState);
                }
                break;
                #endregion

                #region [0x0c] - [v2.1] - [Security Status] - [String]
            case SmbiosType003Property.SecurityStatus:
                if (HeaderInfo.Length >= 0x0d)
                {
                    value = GetEnclosureSecurityStatus(SecurityStatus);
                }
                break;
                #endregion

                #region [0x0d] - [v2.3] - [OEM-defined] - [Long?]
            case SmbiosType003Property.OemDefined:
                if (HeaderInfo.Length >= 0x0e)
                {
                    long oemDefined = OemDefined;
                    if (oemDefined != 0)
                    {
                        value = (Int64?)oemDefined;
                    }
                }
                break;
                #endregion

                #region [0x11] - [v2.3] - [Height] - [Byte?]
            case SmbiosType003Property.Height:
                if (HeaderInfo.Length >= 0x12)
                {
                    byte height = Height;
                    if (height != 0)
                    {
                        value = (Byte?)height;
                    }
                }
                break;
                #endregion

                #region [0x12] - [v2.3] - [Number Of Power Cords] - [Byte?]
            case SmbiosType003Property.NumberOfPowerCords:
                if (HeaderInfo.Length >= 0x13)
                {
                    byte numberOfPowerCords = NumberOfPowerCords;
                    if (numberOfPowerCords != 0)
                    {
                        value = (Byte?)numberOfPowerCords;
                    }
                }
                break;
                #endregion

                #region [0x15] - [v2.3] - [Contained Elements] - [ChassisContainedElementCollection]
            case SmbiosType003Property.ContainedElements:
                if (HeaderInfo.Length >= 0x14)
                {
                    byte n = ContainedElementCount;
                    if (n != 0)
                    {
                        if (HeaderInfo.Length >= 0x15)
                        {
                            byte m = ContainedElementRecordLenght;
                            if (m != 0)
                            {
                                if (HeaderInfo.Length >= 0x16)
                                {
                                    var containedElementsArray = new byte[n * m];
                                    Array.Copy(HeaderInfo.RawData, 0x15, containedElementsArray, 0, n * m);

                                    IEnumerable <ChassisContainedElement> containedElements =
                                        GetContainedElements(containedElementsArray, n);
                                    value = new ChassisContainedElementCollection(containedElements);
                                }
                            }
                        }
                    }
                }
                break;
                #endregion

                #region [0x15 + (n * m)] - [v2.3] - [Contained Elements] - [String]
            case SmbiosType003Property.SkuNumber:
                if (HeaderInfo.Length >= 0x14)
                {
                    byte n = ContainedElementCount;
                    if (n != 0)
                    {
                        if (HeaderInfo.Length >= 0x15)
                        {
                            byte m = ContainedElementRecordLenght;
                            if (m != 0)
                            {
                                value = GetEnclosureSkuNumber(n, m);
                            }
                        }
                    }
                }
                break;
                #endregion
            }

            return(value);
        }
Exemplo n.º 44
0
 public ShellRefPropertyImpl(
     PropertyKey propertyKey) : base(
         propertyKey)
 {
 }
Exemplo n.º 45
0
 public int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue)
 {
     return contentEditor.CommandManager.UpdateProperty(commandId, ref key, currentValue, out newValue);
 }
        /// <inheritdoc />
        /// <summary>
        /// Gets a value that represents the value of the specified property.
        /// </summary>
        /// <param name="propertyKey">Property key to be obtained.</param>
        /// <returns>
        /// Property value
        /// </returns>
        protected override object GetValueTypedProperty(PropertyKey propertyKey)
        {
            object value = null;
            SmbiosType002Property propertyId = (SmbiosType002Property)propertyKey.PropertyId;

            switch (propertyId)
            {
                #region [0x04] - [Manufacturer] - [String]
            case SmbiosType002Property.Manufacturer:
                value = Manufacturer;
                break;
                #endregion

                #region [0x05] - [Product] - [String]
            case SmbiosType002Property.Product:
                value = Product;
                break;
                #endregion

                #region [0x06] - [Version] - [String]
            case SmbiosType002Property.Version:
                value = Version;
                break;
                #endregion

                #region [0x07] - [Serial Number] - [String]
            case SmbiosType002Property.SerialNumber:
                value = SerialNumber;
                break;
                #endregion

                #region [0x08] - [Asset Tag] - [String]
            case SmbiosType002Property.AssetTag:
                if (HeaderInfo.Length >= 0x09)
                {
                    value = AssetTag;
                }
                break;
                #endregion

                #region [0x09] - [Feature Flag]

                #region [0x09] - [Feature Flags -> Hot Swappable] - [Boolean?]
            case SmbiosType002Property.HotSwappable:
                if (HeaderInfo.Length >= 0x0a)
                {
                    value = (bool?)IsHotSwappable;
                }
                break;
                #endregion

                #region [0x09] - [Feature Flags -> Is Replaceable] - [Boolean?]
            case SmbiosType002Property.IsReplaceable:
                if (HeaderInfo.Length >= 0x0a)
                {
                    value = (bool?)IsReplaceable;
                }
                break;
                #endregion

                #region [0x09] - [Feature Flags -> Is Removable] - [Boolean?]
            case SmbiosType002Property.IsRemovable:
                if (HeaderInfo.Length >= 0x0a)
                {
                    value = (bool?)IsRemovable;
                }
                break;
                #endregion

                #region [0x09] - [Feature Flags -> Required Daughter Board] - [Boolean?]
            case SmbiosType002Property.RequiredDaughterBoard:
                if (HeaderInfo.Length >= 0x0a)
                {
                    value = (bool?)RequiredDaughterBoard;
                }
                break;
                #endregion

                #region [0x09] - [Feature Flags -> Is Hosting Board] - [Boolean?]
            case SmbiosType002Property.IsHostingBoard:
                if (HeaderInfo.Length >= 0x0a)
                {
                    value = (bool?)IsHostingBoard;
                }
                break;
                #endregion

                #endregion

                #region [0x0a] - [Location In Chassis] - [String]
            case SmbiosType002Property.LocationInChassis:
                if (HeaderInfo.Length >= 0x0b)
                {
                    value = LocationInChassis;
                }
                break;
                #endregion

                #region [0x0b] - [Chassis Handle] - [Int32?]
            case SmbiosType002Property.ChassisHandle:
                if (HeaderInfo.Length >= 0x0c)
                {
                    value = ChassisHandle;
                }
                break;
                #endregion

                #region [0x0d] - [Board Type] - [String]
            case SmbiosType002Property.BoardType:
                if (HeaderInfo.Length >= 0x0e)
                {
                    value = GetBoardType(BoardType);
                }
                break;
                #endregion

                #region [0x0e] - [Number Of Contained Object Handles] - [Byte?]
            case SmbiosType002Property.NumberOfContainedObjectHandles:
                if (HeaderInfo.Length >= 0x0f)
                {
                    value = NumberOfContainedObjectHandles;
                }
                break;
                #endregion

                #region [0x0f] - [Number Of Contained Object Handles] - [BaseBoardContainedElementCollection]
            case SmbiosType002Property.ContainedObjectHandles:
                if (HeaderInfo.Length >= 0x0f)
                {
                    byte n = NumberOfContainedObjectHandles;
                    if (n != 0x00 && HeaderInfo.Length >= 0x10)
                    {
                        var containedElementsArray = new byte[n];
                        Array.Copy(HeaderInfo.RawData, 0x0f, containedElementsArray, 0, n);

                        IEnumerable <SmbiosStructure> containedElements = GetContainedElements(containedElementsArray);
                        value = new BaseBoardContainedElementCollection(containedElements);
                    }
                }
                break;
                #endregion
            }

            return(value);
        }
Exemplo n.º 47
0
 public int CancelOverride(uint commandId, ref PropertyKey key)
 {
     return contentEditor.CommandManager.CancelOverride(commandId, ref key);
 }
Exemplo n.º 48
0
        private AssetVirtualNodePresenter CreateDependencyPropertyNode(IAssetNodePresenter propertyNodeParent, [NotNull] IAssetNodePresenter node, [NotNull] PropertyKey property, int?order)
        {
            var propertyType  = property.PropertyType;
            var propertyIndex = new NodeIndex(property);
            var accessor      = node.GetNodeAccessor();

            var propertyContainerNode = ((IObjectNode)accessor.Node)[nameof(UIElement.DependencyProperties)].Target;

            var undoRedoService = propertyNodeParent.Asset.ServiceProvider.Get <IUndoRedoService>();
            var virtualNode     = node.Factory.CreateVirtualNodePresenter(propertyNodeParent, property.Name, propertyType, order,
                                                                          () => Getter(propertyContainerNode, propertyIndex),
                                                                          o => Setter(undoRedoService, propertyContainerNode, propertyIndex, o));

            return(virtualNode);
        }
Exemplo n.º 49
0
 /// <summary>
 /// Returns a value that represents the value of the specified property.
 /// </summary>
 /// <param name="propertyKey">Key to the property to obtain</param>
 /// <returns>
 /// An <see cref="T:System.Object"/> that contains property.
 /// </returns>
 protected virtual object GetValueTypedProperty(PropertyKey propertyKey) => null;
Exemplo n.º 50
0
 /// <summary>
 ///     Creates a generic ShellProperty.
 /// </summary>
 /// <param name="propKey">PropertyKey</param>
 /// <param name="store">IPropertyStore from which to get property</param>
 /// <returns>ShellProperty matching type of value in property.</returns>
 public static IShellProperty CreateShellProperty(PropertyKey propKey, IPropertyStore store)
 {
     return(GenericCreateShellProperty(propKey, store));
 }
Exemplo n.º 51
0
 /// <summary>
 /// Returns the value of specified property. Always returns the first appearance of the property. If it does not exist, returns <c>null</c> (<c>Nothing</c> in visual basic).
 /// </summary>
 /// <param name="propertyKey">Key to the property to obtain</param>
 /// <returns>
 /// Reference to the object that represents the value of the property. Always returns the first appearance of the property.
 /// </returns>
 public object GetProperty(PropertyKey propertyKey) => GetValueTypedProperty(propertyKey);
Exemplo n.º 52
0
 /// <summary>
 ///     Creates a generic ShellProperty.
 /// </summary>
 /// <param name="propKey">PropertyKey</param>
 /// <param name="shellObject">Shell object from which to get property</param>
 /// <returns>ShellProperty matching type of value in property.</returns>
 public static IShellProperty CreateShellProperty(PropertyKey propKey, ShellObject shellObject)
 {
     return(GenericCreateShellProperty(propKey, shellObject));
 }
Exemplo n.º 53
0
        public bool ContainsProperty(string propertyName)
        {
            PropertyKey pkey = new PropertyKey(propertyName);

            return(_values.ContainsKey(pkey));
        }
Exemplo n.º 54
0
 public void OnPropertyValueChanged(string pwstrDeviceId, PropertyKey key)
 {
     // NOOP
 }
Exemplo n.º 55
0
        public void Gets_Cell_Data(int rowIndex, PropertyKey key, byte[] expectedBytes)
        {
            var reader = new Mock<IPstReader>();
            reader.Setup(r => r.FindBlock(0x538))
                .Returns(Block.Create(_nodeData));
            reader.Setup(r => r.FindBlock(0x542))
                .Returns(Block.Create(_subNodeTree));
            reader.Setup(r => r.FindBlock(0x53c))
                .Returns(Block.Create(_subNodeData));

            var node = new Node(0x802d, 0x538, 0x542, reader.Object);
            var tc = new TableContext(node, reader.Object);

            var row = tc.Rows[rowIndex];
            CollectionAssert.AreEqual(expectedBytes, row.GetCell(key)?.ToArray());
        }
Exemplo n.º 56
0
 void IMMNotificationClient.OnPropertyValueChanged(string pwstrDeviceId, PropertyKey key)
 {
 }
Exemplo n.º 57
0
        /// <summary>
        /// Creates a new column list whose columns are all visible, 
        /// given an array of PropertyKey structures. The default is based on FolderTypeID.
        /// </summary>
        /// <remarks>This property may not work correctly with the ExplorerBrowser control.</remarks>
        public void SetVisibleColumns(PropertyKey[] value)
        {
            HResult hr = NativeSearchFolderItemFactory.SetVisibleColumns(value == null ? 0 : (uint)value.Length, value);

            if (!CoreErrorHelper.Succeeded(hr))
            {
                throw new ShellException(LocalizedMessages.ShellSearchFolderUnableToSetVisibleColumns, Marshal.GetExceptionForHR((int)hr));
            }
        }
Exemplo n.º 58
0
 public static void SetProperty(PropertyKey propertyKey, string value)
 {
     propertyManager.SetProperty(propertyKey, value);
 }
Exemplo n.º 59
0
 /// <summary>
 /// Sets a shell property for a given window
 /// </summary>
 /// <param name="propKey">The property to set</param>
 /// <param name="window">Window that the property will be set on</param>
 /// <param name="value">The value to set for the property</param>
 public static void SetWindowProperty(Window window, PropertyKey propKey, string value)
 {
     TaskbarNativeMethods.SetWindowProperty((new WindowInteropHelper(window)).Handle, propKey, value);
 }
Exemplo n.º 60
0
 public static string GetProperty(PropertyKey propertyKey)
 {
     return(propertyManager.GetProperty(propertyKey));
 }