Ejemplo n.º 1
0
        private void SetValue(object managedValue, ADSTYPE adstype)
        {
            object[] objArray;
            this.adsvalue = new ADSVALUE()
            {
                dwType = adstype
            };
            switch (adstype)
            {
            case ADSTYPE.ADSTYPE_CASE_IGNORE_STRING: {
                this.pinnedHandle     = GCHandle.Alloc(managedValue, GCHandleType.Pinned);
                this.adsvalue.pointer = this.pinnedHandle.AddrOfPinnedObject();
                return;
            }

            case ADSTYPE.ADSTYPE_PRINTABLE_STRING:
            case ADSTYPE.ADSTYPE_NUMERIC_STRING:
            case ADSTYPE.ADSTYPE_OCTET_STRING:
            case ADSTYPE.ADSTYPE_UTC_TIME: {
                objArray = new object[] { string.Concat("0x", Convert.ToString((int)adstype, 16)) };
                throw new NotImplementedException();
            }

            case ADSTYPE.ADSTYPE_BOOLEAN: {
                if ((bool)managedValue)
                {
                    this.LowInt64 = (long)-1;
                    return;
                }
                this.LowInt64 = (long)0;
                return;
            }

            case ADSTYPE.ADSTYPE_INTEGER: {
                this.adsvalue.generic.a = (int)managedValue;
                this.adsvalue.generic.b = 0;
                return;
            }

            case ADSTYPE.ADSTYPE_LARGE_INTEGER: {
                this.LowInt64 = (long)managedValue;
                return;
            }

            case ADSTYPE.ADSTYPE_PROV_SPECIFIC: {
                byte[] numArray = (byte[])managedValue;
                this.adsvalue.octetString.dwLength = (uint)numArray.Length;
                this.pinnedHandle = GCHandle.Alloc(numArray, GCHandleType.Pinned);
                this.adsvalue.octetString.lpValue = this.pinnedHandle.AddrOfPinnedObject();
                return;
            }

            default: {
                objArray = new object[] { string.Concat("0x", Convert.ToString((int)adstype, 16)) };
                throw new NotImplementedException();
            }
            }
        }
Ejemplo n.º 2
0
 public AdsValueHelper(ADSVALUE adsvalue)
 {
     this.adsvalue = adsvalue;
 }