public PrimaryKeySchema GetTablePrimaryKey(string connectionString, TableSchema table)
        {
            ADOX.Catalog catalog   = GetCatalog(connectionString);
            ADOX.Table   adoxtable = catalog.Tables[table.Name];

            if (adoxtable.Keys != null)
            {
                for (int i = 0; i < adoxtable.Keys.Count; i++)
                {
                    if (adoxtable.Keys[i].Type == ADOX.KeyTypeEnum.adKeyPrimary)
                    {
                        string[] memberColumns = new string[adoxtable.Keys[i].Columns.Count];
                        for (int x = 0; x < adoxtable.Keys[i].Columns.Count; x++)
                        {
                            memberColumns[x] = adoxtable.Keys[i].Columns[x].Name;
                        }

                        Cleanup();

                        var extendedProperties = new ExtendedPropertyCollection();
                        extendedProperties.Add(new ExtendedProperty("DeleteRule", adoxtable.Keys[i].DeleteRule.ToString(), DbType.String, PropertyStateEnum.ReadOnly));
                        extendedProperties.Add(new ExtendedProperty("UpdateRule", adoxtable.Keys[i].UpdateRule.ToString(), DbType.String, PropertyStateEnum.ReadOnly));

                        return(new PrimaryKeySchema(table, adoxtable.Keys[i].Name, memberColumns, extendedProperties.ToArray()));
                    }
                }
            }

            Cleanup();

            return(null);
        }
예제 #2
0
        private void UpdateExtendedProperty(ExtendedPropertyCollection exProps)
        {
            object origPropValue = null;

            if (this.CurrentServiceObejct.TryGetProperty(this.CurrentProperty, out origPropValue))
            {
                object currPropValue = GetCurrentPropertyValue(txtType.Text);

                if (origPropValue == null ^ currPropValue == null ||
                    !origPropValue.Equals(currPropValue))
                {
                    if (this.CurrentServiceObejct is Item)
                    {
                        (this.CurrentServiceObejct as Item).SetExtendedProperty(
                            this.CurrentProperty as ExtendedPropertyDefinition,
                            currPropValue);

                        this.IsDirty = true;
                    }
                    else if (this.CurrentServiceObejct is Folder)
                    {
                        (this.CurrentServiceObejct as Folder).SetExtendedProperty(
                            this.CurrentProperty as ExtendedPropertyDefinition,
                            currPropValue);

                        this.IsDirty = true;
                    }
                }
            }
        }
        public ColumnSchema[] GetTableColumns(string connectionString, TableSchema table)
        {
            ADOX.Catalog catalog   = GetCatalog(connectionString);
            ADOX.Table   adoxtable = catalog.Tables[table.Name];

            ArrayList columns = new ArrayList();

            if (adoxtable.Columns != null)
            {
                for (int i = 0; i < adoxtable.Columns.Count; i++)
                {
                    var properties = new ExtendedPropertyCollection(ConvertToExtendedProperties(adoxtable.Columns[i].Properties));
                    if (adoxtable.Columns[i].Properties["Default"] != null)
                    {
                        properties.Add(new ExtendedProperty(ExtendedPropertyNames.DefaultValue, adoxtable.Columns[i].Properties["Default"].Value, DbType.String, PropertyStateEnum.ReadOnly));
                    }

                    bool allowDBNull = adoxtable.Columns[i].Properties["Nullable"] != null && (bool)adoxtable.Columns[i].Properties["Nullable"].Value;
                    columns.Add(new ColumnSchema(
                                    table,
                                    adoxtable.Columns[i].Name,
                                    GetDbType(adoxtable.Columns[i].Type),
                                    adoxtable.Columns[i].Type.ToString(),
                                    adoxtable.Columns[i].DefinedSize,
                                    Convert.ToByte(adoxtable.Columns[i].Precision),
                                    adoxtable.Columns[i].NumericScale,
                                    allowDBNull,
                                    properties.ToArray()));
                }
            }

            Cleanup();

            return((ColumnSchema[])columns.ToArray(typeof(ColumnSchema)));
        }
예제 #4
0
        private bool UpdateExtendedProperties(ExtendedPropertyCollection properties, SqlExtendedPropertyContainer container)
        {
            bool             DoAlter = false;
            ExtendedProperty prop    = null;

            foreach (string key in container.Properties.Keys)
            {
                if (properties.Contains(key))
                {
                    prop = properties[key];
                }
                else
                {
                    prop = new ExtendedProperty(properties.Parent, key);
                    properties.Add(prop);
                    DoAlter = true;
                }
                prop.Value = container.Properties[key];
                prop.Alter();
            }

            foreach (ExtendedProperty prop2 in properties)
            {
                if (!container.Properties.ContainsKey(prop2.Name))
                {
                    prop2.MarkForDrop(true);
                    DoAlter = true;
                }
            }
            return(DoAlter);
        }
예제 #5
0
파일: Classes.cs 프로젝트: pmarflee/TinySql
        private bool UpdateExtendedProperties(ExtendedPropertyCollection properties, SqlExtendedPropertyContainer container)
        {
            bool DoAlter = false;
            ExtendedProperty prop = null;
            foreach (string key in container.Properties.Keys)
            {
                if (properties.Contains(key))
                {
                    prop = properties[key];
                }
                else
                {
                    prop = new ExtendedProperty(properties.Parent, key);
                    properties.Add(prop);
                    DoAlter = true;
                }
                prop.Value = container.Properties[key];
                prop.Alter();
            }

            foreach (ExtendedProperty prop2 in properties)
            {
                if (!container.Properties.ContainsKey(prop2.Name))
                {
                    prop2.MarkForDrop(true);
                    DoAlter = true;
                }
            }
            return DoAlter;

        }
예제 #6
0
        /// <Summary>
        /// Encodes the ExtendedProperties in the ISF stream.
        /// </Summary>
#else
        /// <Summary>
        /// Encodes the ExtendedProperties in the ISF stream.
        /// </Summary>
#endif
        private static void PersistExtendedProperties(DrawingAttributes da, Stream stream, GuidList guidList, ref uint cbData, ref BinaryWriter bw, byte compressionAlgorithm, bool fTag)
        {
            // Now save the extended properties
            ExtendedPropertyCollection epcClone = da.CopyPropertyData();

            //walk from the back removing EPs that are uses for DrawingAttributes
            for (int x = epcClone.Count - 1; x >= 0; x--)
            {
                //
                // look for StylusTipTransform while we're at it and turn it into a string
                // for serialization
                //
                if (epcClone[x].Id == KnownIds.StylusTipTransform)
                {
                    Matrix matrix       = (Matrix)epcClone[x].Value;
                    string matrixString = matrix.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    epcClone[x].Value = matrixString;
                    continue;
                }

                if (DrawingAttributes.RemoveIdFromExtendedProperties(epcClone[x].Id))
                {
                    epcClone.Remove(epcClone[x].Id);
                }
            }

            cbData += ExtendedPropertySerializer.EncodeAsISF(epcClone, stream, guidList, compressionAlgorithm, fTag);
        }
예제 #7
0
 /// <summary>
 ///     Initializes a new instance of the ContextItem class.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <param name="isLocal">if set to <c>true</c> [is local].</param>
 public ContextItem(string key, object value, bool isLocal)
 {
     Guard.ArgumentNotNullOrEmpty(key, "key");
     Guard.ArgumentNotNull(value, "value");
     Key = key;
     Value = value;
     IsLocal = isLocal;
     ExtendedProperties = new ExtendedPropertyCollection(this);
 }
예제 #8
0
파일: Classes.cs 프로젝트: pmarflee/TinySql
 private void RetrieveExtendedProperties(ExtendedPropertyCollection properties, SqlExtendedPropertyContainer container)
 {
     properties.Refresh();
     foreach (ExtendedProperty prop in properties)
     {
         prop.Refresh();
         container.Properties.TryAdd(prop.Name, prop.Value.ToString());
     }
 }
예제 #9
0
 private void RetrieveExtendedProperties(ExtendedPropertyCollection properties, SqlExtendedPropertyContainer container)
 {
     properties.Refresh();
     foreach (ExtendedProperty prop in properties)
     {
         prop.Refresh();
         container.Properties.TryAdd(prop.Name, prop.Value.ToString());
     }
 }
예제 #10
0
        private string[] GetExtendedProperty(string PropertyName, ExtendedPropertyCollection props, char[] separators)
        {
            string value = GetExtendedProperty(PropertyName, props);

            if (value != null)
            {
                return(value.Split(separators, StringSplitOptions.RemoveEmptyEntries));
            }
            return(null);
        }
예제 #11
0
 protected override object[] GetItems(object editValue)
 {
     Collection = (editValue as ExtendedPropertyCollection);
     return(Collection.Keys.Select(k =>
     {
         var ep = Collection.Parent.GetExtendedPropertyType(k) == ExtendedPropertyType.Json ? new JsonExtendedProperty() : new StringExtendedProperty() as ExtendedProperty;
         ep.Name = k;
         ep.Value = Collection[k].ToString();
         return ep;
     }).ToArray());
 }
예제 #12
0
 private string GetExtendedProperty(string PropertyName, ExtendedPropertyCollection props)
 {
     if (props.Count > 0)
     {
         string key = "TinySql." + PropertyName;
         if (props.Contains(key))
         {
             return(Convert.ToString(props[key].Value));
         }
     }
     return(null);
 }
예제 #13
0
        /// <summary>
        /// Add extended properties columns to grid
        /// </summary>
        /// <param name="column">column</param>
        /// <param name="row">row</param>
        /// <param name="gridName">grid name</param>
        /// <param name="propertyName">extended property name</param>
        private void AddColumnToGrid(Column column, DataRow row, string gridName, string propertyName)
        {
            ExtendedPropertyCollection extendedProperties = column.ExtendedProperties;

            if (extendedProperties.Contains(propertyName))
            {
                row[gridName] = column.ExtendedProperties[propertyName].Value;
            }
            else
            {
                row[gridName] = null;
            }
        }
예제 #14
0
        /// <summary>
        /// GetExtendedProperties 取得資料庫延伸屬性的值.
        /// </summary>
        /// <param name="extendedPropertyCollection">The _ extended property collection.</param>
        /// <param name="names">The _name.</param>
        /// <returns></returns>
        private static string GetExtendedProperties(ExtendedPropertyCollection extendedPropertyCollection, params string[] names)
        {
            StringBuilder oSb = new StringBuilder();

            foreach (var name in names)
            {
                if (extendedPropertyCollection.Contains(name) && extendedPropertyCollection[name].Value != null)
                {
                    oSb.Append(extendedPropertyCollection[name].Value.ToString().Trim());
                }
            }
            return(oSb.ToString());
        }
예제 #15
0
 public List<Annotation> GetAnnotations( ExtendedPropertyCollection props )
 {
     var list = new List<Annotation>();
     foreach (ExtendedProperty prop in props)
     {
         list.Add( new Annotation
             {
                 AnnotationType = "Tag",
                 Tag = prop.Name,
                 Value = prop.Value.ToString()
             } );
     }
     return list;
 }
예제 #16
0
 /// <summary>
 /// Retrieve the guids for the custom attributes that are not known by
 /// the v1 ISF decoder
 /// </summary>
 /// <param name="attributes"></param>
 /// <param name="count">count of guids returned (can be less than return.Length</param>
 /// <returns></returns>
 internal static Guid[] GetUnknownGuids(ExtendedPropertyCollection attributes, out int count)
 {
     Guid[] guids = new Guid[attributes.Count];
     count = 0;
     for (int x = 0; x < attributes.Count; x++)
     {
         ExtendedProperty attribute = attributes[x];
         if (0 == GuidList.FindKnownTag(attribute.Id))
         {
             guids[count++] = attribute.Id;
         }
     }
     return(guids);
 }
예제 #17
0
        public List <Annotation> GetAnnotations(ExtendedPropertyCollection props)
        {
            var list = new List <Annotation>();

            foreach (ExtendedProperty prop in props)
            {
                list.Add(new Annotation
                {
                    AnnotationType = "Tag",
                    Tag            = prop.Name,
                    Value          = prop.Value.ToString()
                });
            }
            return(list);
        }
예제 #18
0
    /// <summary>
    /// Load extended properties xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Extended properties collection</returns>
    /* private */ static ExtendedPropertyCollection LoadExtendedPropertiesXml(EwsServiceXmlReader reader)
    {
        ExtendedPropertyCollection extendedProperties = new ExtendedPropertyCollection();

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties);
        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperty))
            {
                extendedProperties.LoadFromXml(reader, XmlElementNames.ExtendedProperty);
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties));

        return(extendedProperties.Count == 0 ? null : extendedProperties);
    }
예제 #19
0
        internal static bool ParseBooleanExtendedProperty(this SchemaObjectBase schemaObjectBase, string extendedProperty)
        {
            if (schemaObjectBase == null)
            {
                return(false);
            }
            ExtendedPropertyCollection loadedExtendedProperties = schemaObjectBase.GetLoadedExtendedProperties();

            if (!loadedExtendedProperties.Contains(extendedProperty))
            {
                return(false);
            }
            bool result;

            bool.TryParse(loadedExtendedProperties[extendedProperty].Value.ToString(), out result);
            return(result);
        }
        public ParameterSchema[] GetCommandParameters(string connectionString, CommandSchema command)
        {
            ADOX.Catalog   catalog       = GetCatalog(connectionString);
            ADOX.Procedure adoxprocedure = catalog.Procedures[command.Name];

            ADODB.Command cmd = (ADODB.Command)adoxprocedure.Command;
            cmd.Parameters.Refresh();

            ParameterSchema[] parameters = new ParameterSchema[cmd.Parameters.Count];

            for (int i = 0; i < cmd.Parameters.Count; i++)
            {
                var  properties  = new ExtendedPropertyCollection(ConvertToExtendedProperties(cmd.Parameters[i].Properties));
                bool allowDBNull = false;

                try
                {
                    allowDBNull = cmd.Parameters[i].Properties["Nullable"] != null && (bool)cmd.Parameters[i].Properties["Nullable"].Value;

                    if (cmd.Parameters[i].Properties["Default"] != null)
                    {
                        properties.Add(new ExtendedProperty(ExtendedPropertyNames.DefaultValue, cmd.Parameters[i].Properties["Default"].Value, DbType.String, PropertyStateEnum.ReadOnly));
                    }
                }
                catch {}

                parameters[i] = new ParameterSchema(
                    command,
                    cmd.Parameters[i].Name,
                    GetParameterDirection(cmd.Parameters[i].Direction),
                    GetDbType(cmd.Parameters[i].Type),
                    cmd.Parameters[i].Type.ToString(),
                    cmd.Parameters[i].Size,
                    cmd.Parameters[i].Precision,
                    cmd.Parameters[i].NumericScale,
                    allowDBNull,
                    properties.ToArray());
            }

            Cleanup();

            return(parameters);
        }
예제 #21
0
        /// <summary>
        /// Saves all elements in this list in the stream passed with the tags being generated based on the GuidList
        /// by the caller and using compressionAlgorithm as the preferred algorith identifier. For ExtendedPropertyCollection associated
        /// with Ink, drawing attributes and Point properties, we need to write the tag while saving them and hence
        /// fTag param is true. For strokes, the Tag is stored in the stroke descriptor and hence we don't store the
        /// tag
        /// </summary>
        /// <param name="attributes">Custom attributes to encode</param>
        /// <param name="stream">If stream is null, then size is calculated only.</param>
        /// <param name="guidList"></param>
        /// <param name="compressionAlgorithm"></param>
        /// <param name="fTag"></param>
#endif
        internal static uint EncodeAsISF(ExtendedPropertyCollection attributes, Stream stream, GuidList guidList, byte compressionAlgorithm, bool fTag)
        {
            uint cbWrite = 0;

            for (int i = 0; i < attributes.Count; i++)
            {
                ExtendedProperty prop = attributes[i];

                using (MemoryStream localStream = new MemoryStream(10)) //reasonable default
                {
                    ExtendedPropertySerializer.EncodeToStream(prop, localStream);

                    byte[] data = localStream.ToArray();

                    cbWrite += ExtendedPropertySerializer.EncodeAsISF(prop.Id, data, stream, guidList, compressionAlgorithm, fTag);
                }
            }

            return(cbWrite);
        }
        internal static UpdateStorageAccountInfo Create(string label, string description, bool geoReplicationEnabled, IDictionary<string, string> extendedProperties)
        {
            Validation.ValidateAllNotNull(label, description, extendedProperties);
            Validation.ValidateDescription(description);
            Validation.ValidateLabel(label, true);
            Validation.ValidateExtendedProperties(extendedProperties);

            ExtendedPropertyCollection collection = null;
            if (extendedProperties != null)
            {
                collection = new ExtendedPropertyCollection(extendedProperties);
            }

            return new UpdateStorageAccountInfo
            {
                Label = string.IsNullOrEmpty(label) ? null : label.EncodeBase64(),
                Description = description,
                GeoReplicationEnabled = geoReplicationEnabled,
                ExtendedProperties = collection
            };
        }
 // Token: 0x06000526 RID: 1318 RVA: 0x00026F5C File Offset: 0x0002515C
 private object[] ConvertToFolderProps(ExtendedPropertyCollection propertyList)
 {
     object[] array = new object[FolderHelper.DataColumns.Length];
     if (propertyList != null)
     {
         foreach (ExtendedProperty extendedProperty in propertyList)
         {
             if (string.Compare("RetentionTagEntryId", extendedProperty.PropertyDefinition.Name, true) == 0)
             {
                 array[8] = extendedProperty.Value;
             }
             else if (extendedProperty.PropertyDefinition.Tag != null)
             {
                 int value = extendedProperty.PropertyDefinition.Tag.Value;
                 int num   = (int)this.retentionPropertyTagsMapping[value];
                 array[num] = extendedProperty.Value;
             }
         }
     }
     return(array);
 }
        internal static ChangeDeploymentConfigurationInfo Create(string configFilePath, bool treatWarningsAsError, UpgradeType mode, IDictionary<string, string> extendedProperties)
        {
            Validation.ValidateStringArg(configFilePath, "configuration");
            Validation.ValidateExtendedProperties(extendedProperties);
            if (!File.Exists(configFilePath)) throw new FileNotFoundException(string.Format(Resources.ConfigFileNotFound, configFilePath), configFilePath);

            string configText = File.ReadAllText(configFilePath);

            ExtendedPropertyCollection collection = null;
            if (extendedProperties != null)
            {
                collection = new ExtendedPropertyCollection(extendedProperties);
            }

            return new ChangeDeploymentConfigurationInfo
            {
                Configuration = configText.EncodeBase64(),
                TreatWarningsAsError = treatWarningsAsError,
                Mode = mode,
                ExtendedProperties = collection
            };
        }
        internal static CreateCloudServiceInfo Create(
            string name, string label, string description,
            string location, string affinityGroup, IDictionary<string,string> extendedProperties)
        {
            Validation.ValidateStringArg(name, "name");
            Validation.ValidateLabel(label);
            Validation.ValidateDescription(description);
            Validation.ValidateLocationOrAffinityGroup(location, affinityGroup);
            Validation.ValidateExtendedProperties(extendedProperties);

            ExtendedPropertyCollection collection = null;
            if (extendedProperties != null)
            {
                collection = new ExtendedPropertyCollection(extendedProperties);
            }

            return new CreateCloudServiceInfo
            {
                Name = name,
                Label = label.EncodeBase64(),
                Description = description,
                Location = location,
                AffinityGroup = affinityGroup,
                ExtendedProperties = collection
            };
        }
        internal static UpgradeDeploymentInfo Create(UpgradeType mode, Uri packageUrl, string configFilePath, string label, string roleToUpgrade, bool treatWarningsAsError, bool force, IDictionary<string, string> extendedProperties)
        {
            Validation.NotNull(packageUrl, "packageUrl");
            Validation.ValidateLabel(label);
            Validation.ValidateStringArg(configFilePath, "configPath");
            Validation.ValidateExtendedProperties(extendedProperties);
            if (!File.Exists(configFilePath)) throw new FileNotFoundException(string.Format(Resources.ConfigFileNotFound, configFilePath), configFilePath);

            string configText = File.ReadAllText(configFilePath);

            ExtendedPropertyCollection collection = null;
            if (extendedProperties != null)
            {
                collection = new ExtendedPropertyCollection(extendedProperties);
            }

            return new UpgradeDeploymentInfo
            {
                Mode = mode,
                PackageUrl = packageUrl,
                Configuration = configText.EncodeBase64(),
                Label = label.EncodeBase64(),
                RoleToUpgrade = roleToUpgrade,
                TreatWarningsAsError = treatWarningsAsError,
                Force = force,
                ExtendedProperties = collection
            };
        }
예제 #27
0
파일: Classes.cs 프로젝트: pmarflee/TinySql
 private string GetExtendedProperty(string PropertyName, ExtendedPropertyCollection props)
 {
     if (props.Count > 0)
     {
         string key = "TinySql." + PropertyName;
         if (props.Contains(key))
         {
             return Convert.ToString(props[key].Value);
         }
     }
     return null;
 }
예제 #28
0
파일: Classes.cs 프로젝트: pmarflee/TinySql
 private string[] GetExtendedProperty(string PropertyName, ExtendedPropertyCollection props, char[] separators)
 {
     string value = GetExtendedProperty(PropertyName, props);
     if (value != null)
     {
         return value.Split(separators, StringSplitOptions.RemoveEmptyEntries);
     }
     return null;
 }
예제 #29
0
        public static ExtendedPropertyCollection MergeExtendedProperties(ExtendedPropertyCollection target, ExtendedPropertyCollection source)
        {
            int num  = 0;
            int num2 = 11;

Label_000D:
            switch (num2)
            {
            case 0:
                return(target);

            case 1:
            case 9:
                num2 = 3;
                goto Label_000D;

            case 2:
                return(target);

            case 3:
                if (num < source.Count)
                {
                    num2 = 10;
                }
                else
                {
                    num2 = 2;
                }
                goto Label_000D;

            case 4:
                target = new ExtendedPropertyCollection();
                num2   = 6;
                goto Label_000D;

            case 5:
                goto Label_0130;

            case 6:
                break;

            case 7:
                target.Add(new ExtendedProperty(source[num].Name, source[num].Value, source[num].DataType));
                num2 = 5;
                goto Label_000D;

            case 8:
                if (source != null)
                {
                    num  = 0;
                    num2 = 9;
                }
                else
                {
                    num2 = 0;
                }
                goto Label_000D;

            case 10:
                if (target.Contains(source[num].Name))
                {
                    goto Label_0130;
                }
                num2 = 7;
                goto Label_000D;

            default:
                if (target == null)
                {
                    num2 = 4;
                    goto Label_000D;
                }
                break;
            }
            num2 = 8;
            goto Label_000D;
Label_0130:
            num++;
            goto Label_0137;

Label_0137:
            num2 = 1;
            goto Label_000D;
        }
예제 #30
0
        /// <summary>
        /// This functions loads a stroke from a memory stream based on the descriptor and GuidList. It returns
        /// the no of bytes it has read from the stream to correctly load the stream, which should be same as
        /// the value of the size parameter. If they are unequal throws ArgumentException. Stroke descriptor is
        /// used to load the packetproperty as well as ExtendedPropertyCollection on this stroke. Compressor is used
        /// to decompress the data.
        /// </summary>
        /// <param name="compressor"></param>
        /// <param name="stream"></param>
        /// <param name="totalBytesInStrokeBlockOfIsfStream"></param>
        /// <param name="guidList"></param>
        /// <param name="strokeDescriptor"></param>
        /// <param name="stylusPointDescription"></param>
        /// <param name="transform"></param>
        /// <param name="stylusPoints"></param>
        /// <param name="extendedProperties"></param>
        /// <returns></returns>
#else
        /// <summary>
        /// This functions loads a stroke from a memory stream based on the descriptor and GuidList. It returns
        /// the no of bytes it has read from the stream to correctly load the stream, which should be same as
        /// the value of the size parameter. If they are unequal throws ArgumentException. Stroke descriptor is
        /// used to load the packetproperty as well as ExtendedPropertyCollection on this stroke. Compressor is used
        /// to decompress the data.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="totalBytesInStrokeBlockOfIsfStream"></param>
        /// <param name="guidList"></param>
        /// <param name="strokeDescriptor"></param>
        /// <param name="stylusPointDescription"></param>
        /// <param name="transform"></param>
        /// <param name="stylusPoints"></param>
        /// <param name="extendedProperties"></param>
#endif
        static uint DecodeISFIntoStroke(
#if OLD_ISF
            Compressor compressor,
#endif
            Stream stream,
            uint totalBytesInStrokeBlockOfIsfStream,
            GuidList guidList,
            StrokeDescriptor strokeDescriptor,
            StylusPointDescription stylusPointDescription,
            Matrix transform,
            out StylusPointCollection stylusPoints,
            out ExtendedPropertyCollection extendedProperties)
        {
            stylusPoints       = null;
            extendedProperties = null;

            // We do allow a stroke with no packet data
            if (0 == totalBytesInStrokeBlockOfIsfStream)
            {
                return(0);
            }

            uint locallyDecodedBytes;
            uint remainingBytesInStrokeBlock = totalBytesInStrokeBlockOfIsfStream;

            // First try to load any packet data
            locallyDecodedBytes = LoadPackets(stream,
                                              remainingBytesInStrokeBlock,
#if OLD_ISF
                                              compressor,
#endif
                                              stylusPointDescription,
                                              transform,
                                              out stylusPoints);

            if (locallyDecodedBytes > remainingBytesInStrokeBlock)
            {
                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Packet buffer overflowed the ISF stream"));
            }

            remainingBytesInStrokeBlock -= locallyDecodedBytes;
            if (0 == remainingBytesInStrokeBlock)
            {
                return(locallyDecodedBytes);
            }

            // Now read the extended propertes
            for (int iTag = 1; iTag < strokeDescriptor.Template.Count && remainingBytesInStrokeBlock > 0; iTag++)
            {
                KnownTagCache.KnownTagIndex tag = strokeDescriptor.Template[iTag - 1];

                switch (tag)
                {
                case MS.Internal.Ink.InkSerializedFormat.KnownTagCache.KnownTagIndex.StrokePropertyList:
                {
                    // we've found the stroke extended properties. Load them now.
                    while (iTag < strokeDescriptor.Template.Count && remainingBytesInStrokeBlock > 0)
                    {
                        tag = strokeDescriptor.Template[iTag];

                        object data;
                        Guid   guid = guidList.FindGuid(tag);
                        if (guid == Guid.Empty)
                        {
                            throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Stroke Custom Attribute tag embedded in ISF stream does not match guid table"));
                        }

                        // load the extended property data from the stream (and decode the type)
                        locallyDecodedBytes = ExtendedPropertySerializer.DecodeAsISF(stream, remainingBytesInStrokeBlock, guidList, tag, ref guid, out data);

                        // add the guid/data pair into the property collection (don't redecode the type)
                        if (extendedProperties == null)
                        {
                            extendedProperties = new ExtendedPropertyCollection();
                        }
                        extendedProperties[guid] = data;
                        if (locallyDecodedBytes > remainingBytesInStrokeBlock)
                        {
                            throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Invalid ISF data"));
                        }

                        remainingBytesInStrokeBlock -= locallyDecodedBytes;
                        iTag++;
                    }
                }
                break;

                case MS.Internal.Ink.InkSerializedFormat.KnownTagCache.KnownTagIndex.Buttons:
                {
                    // Next tag is count of buttons and the tags for the button guids
                    iTag += (int)((uint)strokeDescriptor.Template[iTag]) + 1;
                }
                break;

                // ignore any tags embedded in the Stroke block that this
                //      version of the ISF decoder doesn't understand
                default:
                {
                    System.Diagnostics.Trace.WriteLine("Ignoring unhandled stroke tag in ISF stroke descriptor");
                }
                break;
                }
            }

            // Now try to load any tagged property data or point property data
            while (remainingBytesInStrokeBlock > 0)
            {
                // Read the tag first
                KnownTagCache.KnownTagIndex tag;
                uint uiTag;

                locallyDecodedBytes = SerializationHelper.Decode(stream, out uiTag);
                tag = (KnownTagCache.KnownTagIndex)uiTag;
                if (locallyDecodedBytes > remainingBytesInStrokeBlock)
                {
                    throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Invalid ISF data"));
                }

                remainingBytesInStrokeBlock -= locallyDecodedBytes;

                // if it is a point property block
                switch (tag)
                {
                case MS.Internal.Ink.InkSerializedFormat.KnownTagCache.KnownTagIndex.PointProperty:
                {
                    // First load the totalBytesInStrokeBlockOfIsfStream of the point property block
                    uint cbsize;

                    locallyDecodedBytes = SerializationHelper.Decode(stream, out cbsize);
                    if (locallyDecodedBytes > remainingBytesInStrokeBlock)
                    {
                        throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Invalid ISF data"));
                    }

                    remainingBytesInStrokeBlock -= locallyDecodedBytes;
                    while (remainingBytesInStrokeBlock > 0)
                    {
                        // First read the tag corresponding to the property
                        locallyDecodedBytes = SerializationHelper.Decode(stream, out uiTag);
                        tag = (KnownTagCache.KnownTagIndex)uiTag;
                        if (locallyDecodedBytes > remainingBytesInStrokeBlock)
                        {
                            throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Invalid ISF data"));
                        }

                        remainingBytesInStrokeBlock -= locallyDecodedBytes;

                        // Now read the packet index for which the property will apply
                        uint propindex;

                        locallyDecodedBytes = SerializationHelper.Decode(stream, out propindex);
                        if (locallyDecodedBytes > remainingBytesInStrokeBlock)
                        {
                            throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Invalid ISF data"));
                        }

                        remainingBytesInStrokeBlock -= locallyDecodedBytes;

                        uint propsize;

                        locallyDecodedBytes = SerializationHelper.Decode(stream, out propsize);
                        if (locallyDecodedBytes > remainingBytesInStrokeBlock)
                        {
                            throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Invalid ISF data"));
                        }

                        remainingBytesInStrokeBlock -= locallyDecodedBytes;

                        // Compressed data totalBytesInStrokeBlockOfIsfStream
                        propsize += 1;

                        // Make sure we have enough data to read
                        if (propsize > remainingBytesInStrokeBlock)
                        {
                            throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Invalid ISF data"));
                        }

                        byte[] in_buffer = new byte[propsize];

                        uint bytesRead = StrokeCollectionSerializer.ReliableRead(stream, in_buffer, propsize);
                        if (propsize != bytesRead)
                        {
                            throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Read different size from stream then expected"));
                        }

                        byte[] out_buffer = Compressor.DecompressPropertyData(in_buffer);

                        System.Diagnostics.Debug.Assert(false, "ExtendedProperties for points are not supported");

                        // skip the bytes in both success & failure cases
                        // Note: Point ExtendedProperties are discarded
                        remainingBytesInStrokeBlock -= propsize;
                    }
                }
                break;

                default:
                {
                    object data;
                    Guid   guid = guidList.FindGuid(tag);
                    if (guid == Guid.Empty)
                    {
                        throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Stroke Custom Attribute tag embedded in ISF stream does not match guid table"));
                    }

                    // load the extended property data from the stream (and decode the type)
                    locallyDecodedBytes = ExtendedPropertySerializer.DecodeAsISF(stream, remainingBytesInStrokeBlock, guidList, tag, ref guid, out data);

                    // add the guid/data pair into the property collection (don't redecode the type)
                    if (extendedProperties == null)
                    {
                        extendedProperties = new ExtendedPropertyCollection();
                    }
                    extendedProperties[guid] = data;
                    if (locallyDecodedBytes > remainingBytesInStrokeBlock)
                    {
                        throw new InvalidOperationException(StrokeCollectionSerializer.ISFDebugMessage("ExtendedProperty decoded totalBytesInStrokeBlockOfIsfStream exceeded ISF stream totalBytesInStrokeBlockOfIsfStream"));
                    }

                    remainingBytesInStrokeBlock -= locallyDecodedBytes;
                }
                break;
                }
            }

            if (0 != remainingBytesInStrokeBlock)
            {
                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Invalid ISF data"));
            }

            return(totalBytesInStrokeBlockOfIsfStream);
        }
예제 #31
0
 public virtual void Refresh()
 {
     this._extendedProperties    = null;
     this._gotExtendedProperties = false;
 }
예제 #32
0
        /// <summary>
        /// Determines whether the specified SqlSmoObject is excluded from scripting.
        /// </summary>
        /// <param name="sqlSmoObject">The SqlSmoObject.</param>
        /// <returns>
        ///     <c>true</c> if the SqlSmoObject is system or default and shoudl be excludeed; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsExcludedObject(SqlSmoObject sqlSmoObject)
        {
            // Exclude "IsSystemObject" objects
            try
            {
                bool isSystemObject = (bool)sqlSmoObject.GetType().InvokeMember(
                    "IsSystemObject",
                    BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty,
                    null,
                    sqlSmoObject,
                    null);
                if (isSystemObject)
                {
                    return(true);
                }
            }
            catch (MissingMemberException)
            {
            }

            // Exclude default system MessageTypes
            if (sqlSmoObject is MessageType)
            {
                if (((MessageType)sqlSmoObject).ID <= 65535)
                {
                    return(true);
                }
            }

            // Exclude default system ServiceContractS
            if (sqlSmoObject is ServiceContract)
            {
                if (((ServiceContract)sqlSmoObject).ID <= 65535)
                {
                    return(true);
                }
            }

            // Exclude default system ServiceQueues (Bit 7 128?)
            if (sqlSmoObject is ServiceQueue)
            {
                if (Array.IndexOf(Config.aDefaultServiceQueues, sqlSmoObject.ToString()) != -1)
                {
                    return(true);
                }
            }

            // Exclude default system ServiceRoutes
            // A single default route [AutoCreatedLocal] ID:65536 exists
            // 65537 is user created
            if (sqlSmoObject is ServiceRoute)
            {
                if (((ServiceRoute)sqlSmoObject).ID <= 65536)
                {
                    return(true);
                }
            }

            // Exclude default system BrokerService
            if (sqlSmoObject is BrokerService)
            {
                if (((BrokerService)sqlSmoObject).ID <= 65535)
                {
                    return(true);
                }
            }

            // Exclude "microsoft_database_tools_support" objects
            try
            {
                ExtendedPropertyCollection epc =
                    (ExtendedPropertyCollection)sqlSmoObject.GetType().InvokeMember(
                        "ExtendedProperties",
                        BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty,
                        null,
                        sqlSmoObject,
                        null);
                if (epc.Contains("microsoft_database_tools_support"))
                {
                    return(true);
                }
            }
            catch (MissingMemberException)
            {
            }

            return(false);
        }
        /// <summary>
        /// Load extended properties xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Extended properties collection</returns>
        private static ExtendedPropertyCollection LoadExtendedPropertiesXml(EwsServiceXmlReader reader)
        {
            ExtendedPropertyCollection extendedProperties = new ExtendedPropertyCollection();

            reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties);
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ExtendedProperty))
                {
                    extendedProperties.LoadFromXml(reader, XmlElementNames.ExtendedProperty);
                }
            }
            while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.ExtendedProperties));

            return extendedProperties.Count == 0 ? null : extendedProperties;
        }
        public TableKeySchema[] GetTableKeys(string connectionString, TableSchema table)
        {
            ADOX.Catalog catalog   = GetCatalog(connectionString);
            ADOX.Table   adoxtable = catalog.Tables[table.Name];

            List <TableKeySchema> keys = new List <TableKeySchema>();

            if (adoxtable.Keys != null)
            {
                for (int i = 0; i < adoxtable.Keys.Count; i++)
                {
                    if (adoxtable.Keys[i].Type == ADOX.KeyTypeEnum.adKeyForeign)
                    {
                        string[] primaryKeyMemberColumns = new string[adoxtable.Keys[i].Columns.Count];
                        string[] foreignKeyMemberColumns = new string[adoxtable.Keys[i].Columns.Count];

                        for (int x = 0; x < adoxtable.Keys[i].Columns.Count; x++)
                        {
                            primaryKeyMemberColumns[x] = adoxtable.Keys[i].Columns[x].RelatedColumn;
                            foreignKeyMemberColumns[x] = adoxtable.Keys[i].Columns[x].Name;
                        }

                        var extendedProperties = new ExtendedPropertyCollection();
                        extendedProperties.Add(new ExtendedProperty("DeleteRule", adoxtable.Keys[i].DeleteRule.ToString(), DbType.String, PropertyStateEnum.ReadOnly));
                        extendedProperties.Add(new ExtendedProperty("UpdateRule", adoxtable.Keys[i].UpdateRule.ToString(), DbType.String, PropertyStateEnum.ReadOnly));

                        keys.Add(new TableKeySchema(table.Database, adoxtable.Keys[i].Name, foreignKeyMemberColumns, table.Name, primaryKeyMemberColumns, adoxtable.Keys[i].RelatedTable, extendedProperties.ToArray()));
                    }
                }
            }

            for (int i = 0; i < catalog.Tables.Count; i++)
            {
                var catalogKeys = catalog.Tables[i].Keys;
                if (catalogKeys == null)
                {
                    continue;
                }

                for (int x = 0; x < catalogKeys.Count; x++)
                {
                    if (catalogKeys[x].RelatedTable == table.Name && catalogKeys[x].Type == ADOX.KeyTypeEnum.adKeyForeign)
                    {
                        string[] primaryKeyMemberColumns = new string[catalogKeys[x].Columns.Count];
                        string[] foreignKeyMemberColumns = new string[catalogKeys[x].Columns.Count];

                        for (int y = 0; y < catalogKeys[x].Columns.Count; y++)
                        {
                            primaryKeyMemberColumns[y] = catalogKeys[x].Columns[y].Name;
                            foreignKeyMemberColumns[y] = catalogKeys[x].Columns[y].RelatedColumn;
                        }

                        var extendedProperties = new ExtendedPropertyCollection();
                        extendedProperties.Add(new ExtendedProperty("DeleteRule", catalogKeys[x].DeleteRule.ToString(), DbType.String, PropertyStateEnum.ReadOnly));
                        extendedProperties.Add(new ExtendedProperty("UpdateRule", catalogKeys[x].UpdateRule.ToString(), DbType.String, PropertyStateEnum.ReadOnly));
                        keys.Add(new TableKeySchema(table.Database, catalogKeys[x].Name, foreignKeyMemberColumns, catalog.Tables[i].Name, primaryKeyMemberColumns, table.Name, extendedProperties.ToArray()));
                    }
                }
            }

            Cleanup();

            return(keys.ToArray());
        }
        internal static CreateDeploymentInfo Create(
            string name, Uri packageUrl, string label,
            string configPath, bool startDeployment = false,
            bool treatWarningsAsError = false,
            IDictionary<string, string> extendedProperties = null)
        {
            Validation.ValidateStringArg(name, "name");
            Validation.NotNull(packageUrl, "packageUrl");
            Validation.ValidateLabel(label);
            Validation.ValidateStringArg(configPath, "configPath");
            Validation.ValidateExtendedProperties(extendedProperties);
            if (!File.Exists(configPath)) throw new FileNotFoundException(string.Format(Resources.ConfigFileNotFound, configPath), configPath);

            string configText = File.ReadAllText(configPath);

            ExtendedPropertyCollection collection = null;
            if (extendedProperties != null)
            {
                collection = new ExtendedPropertyCollection(extendedProperties);
            }

            return new CreateDeploymentInfo
            {
                Name = name,
                PackageUrl = packageUrl,
                Label = label.EncodeBase64(),
                Configuration = configText.EncodeBase64(),
                StartDeployment = startDeployment,
                TreatWarningsAsError = treatWarningsAsError,
                ExtendedProperties = collection
            };
        }
        internal static UpdateCloudServiceInfo Create(
            string label, string description, string location, string affinityGroup, IDictionary<string,string> extendedProperties)
        {
            Validation.ValidateAllNotNull(label, description, location, affinityGroup, extendedProperties);
            Validation.ValidateLabel(label, true);
            Validation.ValidateDescription(description);
            Validation.ValidateExtendedProperties(extendedProperties);

            if(!string.IsNullOrEmpty(location) || !string.IsNullOrEmpty(affinityGroup))
            {
                Validation.ValidateLocationOrAffinityGroup(location, affinityGroup);
            }

            ExtendedPropertyCollection collection = null;
            if (extendedProperties != null)
            {
                collection = new ExtendedPropertyCollection(extendedProperties);
            }

            return new UpdateCloudServiceInfo
            {
                Label = string.IsNullOrEmpty(label) ? null : label.EncodeBase64(),
                Description = description,
                Location = location,
                AffinityGroup = affinityGroup,
                ExtendedProperties = collection
            };
        }
        internal static CreateStorageAccountInfo Create(string storageAccountName, string description, string label,
                                                        string affinityGroup, string location, bool geoReplicationEnabled, IDictionary<string, string> extendedProperties)
        {
            Validation.ValidateStorageAccountName(storageAccountName);
            Validation.ValidateDescription(description);
            Validation.ValidateLabel(label);
            Validation.ValidateLocationOrAffinityGroup(location, affinityGroup);
            Validation.ValidateExtendedProperties(extendedProperties);

            ExtendedPropertyCollection collection = null;
            if (extendedProperties != null)
            {
                collection = new ExtendedPropertyCollection(extendedProperties);
            }

            return new CreateStorageAccountInfo
            {
                Name = storageAccountName,
                Description = description,
                Label = label.EncodeBase64(),
                AffinityGroup = affinityGroup,
                Location = location,
                GeoReplicationEnabled = geoReplicationEnabled,
                ExtendedProperties = collection
            };
        }