Exemple #1
0
        /// <summary>
        /// Translates the namedObject's Name to a code-friendly name
        /// </summary>
        /// <param name="namedObject">The named object.</param>
        /// <returns></returns>
        public virtual string Name(INamedObject namedObject)
        {
            var name   = NameFixer.ToPascalCase(namedObject.Name);
            var column = namedObject as DatabaseColumn;

            if (column != null)
            {
                //if it's a foreign key (CategoryId)
                if (column.IsForeignKey && name.Length > 2)
                {
                    if (name.EndsWith("Id", StringComparison.OrdinalIgnoreCase))
                    {
                        //remove the "Id" - it's just a "Category"
                        name = name.Substring(0, name.Length - 2);
                    }
                }

                //member name cannot be same as class name
                if (name == column.Table.NetName)
                {
                    name += "Property";
                }
            }
            return(name);
        }
        public string FormatNamedObject(string prefix, INamedObject namedObject)
        {
            prefix.ThrowIfNull("prefix");
            namedObject.ThrowIfNull("namedObject");

            return String.Format("{0}: {1} ({2})", prefix, namedObject.Name, namedObject.Id);
        }
Exemple #3
0
 // Token: 0x06000094 RID: 148 RVA: 0x00002A70 File Offset: 0x00000C70
 public ConnectionParameters(INamedObject id, ILog log, long maxBytesToTransfer = 9223372036854775807L, int timeout = 300000)
 {
     this.Id  = id;
     this.Log = log;
     this.MaxBytesToTransfer = maxBytesToTransfer;
     this.Timeout            = timeout;
 }
Exemple #4
0
        protected static string FormatNamedObjectDetailText(string prefix, INamedObject namedObject)
        {
            prefix.ThrowIfNull("prefix");
            namedObject.ThrowIfNull("namedObject");

            return DetailTextFormatter.Instance.FormatNamedObject(prefix, namedObject);
        }
 public EasConnectionParameters(INamedObject id, ILog log, EasProtocolVersion easProtocolVersion = EasProtocolVersion.Version140, bool acceptMultipart = false, bool requestCompression = false, string clientLanguage = null) : base(id, log, long.MaxValue, 300000)
 {
     this.EasProtocolVersion = easProtocolVersion;
     this.AcceptMultipart    = acceptMultipart;
     this.RequestCompression = requestCompression;
     this.ClientLanguage     = clientLanguage;
 }
Exemple #6
0
        /// <summary>
        /// Clear data rows where the foreign key is missing.
        /// </summary>
        /// <param name="table">Table for which to manipulate data.</param>
        /// <param name="dataToManipulate">Data rows which should be manipulated.</param>
        /// <param name="keyValuesToClear">Key values for the rows, where the value should be cleared.</param>
        /// <param name="foreignKeyFields">Field in the foreign key.</param>
        /// <param name="keyValueComparer">Functionality to compare key values.</param>
        /// <returns>Data rows where value for the foreign key missing is cleaned.</returns>
        private IEnumerable <IEnumerable <IDataObjectBase> > ClearDataRows(INamedObject table, ICollection <IEnumerable <IDataObjectBase> > dataToManipulate, IList <string> keyValuesToClear, IList <IField> foreignKeyFields, IEqualityComparer <string> keyValueComparer)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            if (dataToManipulate == null)
            {
                throw new ArgumentNullException("dataToManipulate");
            }
            if (keyValuesToClear == null)
            {
                throw new ArgumentNullException("keyValuesToClear");
            }
            if (foreignKeyFields == null)
            {
                throw new ArgumentNullException("foreignKeyFields");
            }
            if (keyValueComparer == null)
            {
                throw new ArgumentNullException("keyValueComparer");
            }
            var dataRowsToClear = new List <IEnumerable <IDataObjectBase> >();

            try
            {
                while (keyValuesToClear.Count > 0)
                {
                    dataRowsToClear.AddRange(DataRepositoryHelper.GetDataRowsForKeyValue(foreignKeyFields, dataToManipulate, keyValuesToClear.ElementAt(0)));
                    keyValuesToClear.RemoveAt(0);
                }
                dataRowsToClear.ForEach(dataRow =>
                {
                    var dataObject = dataRow.Single(m => m.Field != null && m.Field.Equals(foreignKeyFields.Last()));
                    dataObject.UpdateSourceValue <object>(null);
                });
                var foreignKeyInformationBuilder = new StringBuilder();
                foreignKeyInformationBuilder.AppendFormat("{0}(", ForeignKeyTable.NameTarget);
                for (var i = 0; i < _foreignKeyFields.Count; i++)
                {
                    if (i > 0)
                    {
                        foreignKeyInformationBuilder.AppendFormat(", {0}", _foreignKeyFields.ElementAt(i));
                        continue;
                    }
                    foreignKeyInformationBuilder.Append(_foreignKeyFields.ElementAt(i));
                }
                foreignKeyInformationBuilder.Append(')');
                InformationLogger.LogInformation(Resource.GetText(Text.ForeignKeyCleanerInformation, GetType().Name, dataRowsToClear.Count, table.NameTarget, foreignKeyInformationBuilder.ToString()));
                return(dataToManipulate);
            }
            finally
            {
                while (dataRowsToClear.Count > 0)
                {
                    dataRowsToClear.Clear();
                }
            }
        }
Exemple #7
0
 public void ValidateUniqueName(INamedObjectCollection container, INamedObject namedObject, string proposedName)
 {
     this.ValidateName(proposedName);
     if (this.NameExist(container, namedObject, proposedName))
     {
         throw new NameValidationException(System.Design.SR.GetString("CM_NameExist", new object[] { proposedName }));
     }
 }
Exemple #8
0
        public void Remove(string name)
        {
            INamedObject obj2 = NamedObjectUtil.Find(this, name);

            if (obj2 != null)
            {
                base.List.Remove(obj2);
            }
        }
Exemple #9
0
        public void AppendToActiveProject(INamedObject edt)
        {
            VSProjectNode activeProjectNode = GetActiveProjectNode();

            activeProjectNode.AddModelElementsToProject(new List <MetadataReference>
            {
                new MetadataReference(edt.Name, edt.GetType())
            });
        }
 private void UpdateNonOwnerContainer(
     INamedObject oObj,
     INamedObjectList oContainer)
 {
     AddChildCommon(
         oContainer,
         oObj,
         false);
 }
        public virtual INamedObject CreateObject(Type oType, string sName)
        {
            // Create object instance
            INamedObject oObj = (INamedObject)Activator.CreateInstance(
                oType,
                new object[] { sName });

            return(oObj);
        }
Exemple #12
0
            /// <inheritdoc />
            public IFileNode WithChild <T>
                (INamedObject <T> obj)
                where T : ISelfSerializable, new()
            {
                var result = Create(obj);

                Next = result;
                return(result);
            }
Exemple #13
0
 public void SetTag(INamedObject obj)
 {
     lock (((ICollection)m_tagList).SyncRoot)
     {
         m_tagList.Add(new Tag {
             ID = obj.GetID(), Name = obj.GetName(), Count = 1
         });
     }
 }
        string ICustomTypeDescriptor.GetComponentName()
        {
            INamedObject obj2 = this as INamedObject;

            if (obj2 == null)
            {
                return(null);
            }
            return(obj2.Name);
        }
Exemple #15
0
        /// <summary>
        ///     Inserts a new node with the given object after the node at
        ///     the specified depth.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="obj">The contents of the node.</param>
        /// <param name="depth">The depth of the node's parent.</param>
        /// <returns>The created file node.</returns>
        public IFileNode Insert <TValue>
            (INamedObject <TValue> obj,
            int depth)
            where TValue : ISelfSerializable, new()
        {
            var result = FileNode.Create(obj);

            InsertInternal(Root[depth], result);
            return(result);
        }
        public void Set(IDesignConnection connection)
        {
            INamedObject obj2 = NamedObjectUtil.Find(this, connection.Name);

            if (obj2 != null)
            {
                base.List.Remove(obj2);
            }
            base.List.Add(connection);
        }
        private void AddChildCommon(
            INamedObjectList oContainer,
            INamedObject oChild,
            bool bOwner)
        {
            // Register the container as parent of the entity
            (oChild as IEntityBase).AddParentContainer(oContainer, bOwner);

            SetUniqueParentLinkIfNeeded(oChild);
        }
        public string GetObjectName(object oObj)
        {
            INamedObject oNamedObj = oObj as INamedObject;

            if (oNamedObj != null)
            {
                return(oNamedObj.Name);
            }

            return(oObj.GetType().FullName);
        }
Exemple #19
0
 /// <summary>
 /// Compare source name on the two named objects.
 /// </summary>
 /// <param name="x">Named object.</param>
 /// <param name="y">Named object.</param>
 /// <returns>Whether the source name are eqaul on the two name objects.</returns>
 public virtual bool Equals(INamedObject x, INamedObject y)
 {
     if (x == null)
     {
         throw new ArgumentNullException("x");
     }
     if (y == null)
     {
         throw new ArgumentNullException("y");
     }
     return(string.Equals(x.NameSource, y.NameSource));
 }
Exemple #20
0
 /// <summary>
 /// Returns the hash code for the named object.
 /// </summary>
 /// <param name="obj">Named object.</param>
 /// <returns>Hash code.</returns>
 public virtual int GetHashCode(INamedObject obj)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     if (obj.NameSource == null)
     {
         throw new DeliveryEngineSystemException(Resource.GetExceptionMessage(ExceptionMessage.IllegalValue, obj.NameSource, "obj.NameSource"));
     }
     return(obj.NameSource.GetHashCode());
 }
Exemple #21
0
        /// <summary>
        /// Returns an instance when an item was added.
        /// </summary>
        public static NamedObjectCollectionChangedEventArgs FromItemRenamed(INamedObject item, string oldName)
        {
            if (null == item)
            {
                throw new ArgumentNullException("item");
            }
            var result = new NamedObjectCollectionChangedEventArgs()
            {
                _item = item, _newItemName = item.Name, _oldItemName = oldName, _operation = NamedObjectCollectionChangeType.ItemRenamed
            };

            return(result);
        }
        private void UpdateOwnerContainer(
            INamedObject oObj,
            INamedObjectList oContainer)
        {
            // Set child "OwnerParent" field
            SetObjectOwnerParent(
                oObj,
                this);

            AddChildCommon(
                oContainer,
                oObj,
                true);
        }
Exemple #23
0
 private bool NameExist(ICollection container, INamedObject objTobeChecked, string nameTobeChecked)
 {
     if (StringUtil.Empty(nameTobeChecked) && (objTobeChecked != null))
     {
         nameTobeChecked = objTobeChecked.Name;
     }
     foreach (INamedObject obj2 in container)
     {
         if ((obj2 != objTobeChecked) && StringUtil.EqualValue(obj2.Name, nameTobeChecked, !this.caseSensitive))
         {
             return(true);
         }
     }
     return(false);
 }
 private bool NameExist(ICollection container, INamedObject objTobeChecked, string nameTobeChecked)
 {
     if (StringUtil.Empty(nameTobeChecked) && (objTobeChecked != null))
     {
         nameTobeChecked = objTobeChecked.Name;
     }
     foreach (INamedObject obj2 in container)
     {
         if ((obj2 != objTobeChecked) && StringUtil.EqualValue(obj2.Name, nameTobeChecked, !this.caseSensitive))
         {
             return true;
         }
     }
     return false;
 }
Exemple #25
0
        private static INamedObject Find(ICollection coll, string name, bool ignoreCase)
        {
            IEnumerator enumerator = coll.GetEnumerator();

            while (enumerator.MoveNext())
            {
                INamedObject current = enumerator.Current as INamedObject;
                if (current == null)
                {
                    throw new InternalException("Named object collection holds something that is not a named object", 2);
                }
                if (StringUtil.EqualValue(current.Name, name, ignoreCase))
                {
                    return(current);
                }
            }
            return(null);
        }
Exemple #26
0
        /// <summary>
        /// The On Paint event handler
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event arguments</param>
        protected void onPaint(object sender, PaintEventArgs e)
        {
            Graphics g     = e.Graphics;
            Brush    brush = (theObject == null) ? captionInactiveBrush : captionBrush;

            g.FillRectangle(brush, EditorRectangle);
            Pen pen = (theObject == null) ? borderInactivePen : borderPen;

            g.DrawRectangle(pen, 0, 0, Width - 1, Height - 1);
            g.DrawString(ComponentName, font, textBrush, 5F, 5F);
            if (theObject != null)
            {
                if (theObject is INamedObject)
                {
                    INamedObject no   = theObject as INamedObject;
                    string       name = no.Name;
                    g.DrawString(name, font, nameBrush, 5, captionHeight + 2);
                }
            }
        }
Exemple #27
0
 /// <summary>
 /// Translates the namedObject's Name to a code-friendly name
 /// </summary>
 /// <param name="namedObject">The named object.</param>
 /// <returns></returns>
 public virtual string Name(INamedObject namedObject)
 {
     var name = NameFixer.ToPascalCase(namedObject.Name);
     var column = namedObject as DatabaseColumn;
     if (column != null)
     {
         //if it's a foreign key (CategoryId)
         if (column.IsForeignKey && name.EndsWith("Id", StringComparison.OrdinalIgnoreCase) && name.Length > 2)
         {
             //remove the "Id" - it's just a "Category"
             name = name.Substring(0, name.Length - 2);
         }
         //member name cannot be same as class name
         if (name == column.Table.NetName)
         {
             name += "Property";
         }
     }
     return name;
 }
Exemple #28
0
        public void ResolveReferences(Class374 modelBuilder)
        {
            if (this.ulong_0 == 0UL)
            {
                return;
            }
            DxfObject dxfObject = modelBuilder.method_4 <DxfObject>(this.ulong_0);

            if (dxfObject == null || dxfObject.Reference == null || dxfObject.Reference.Value == null)
            {
                return;
            }
            INamedObject namedObject = dxfObject as INamedObject;

            if (namedObject != null && string.IsNullOrEmpty(namedObject.Name))
            {
                namedObject.Name = this.dxfDictionaryEntry_0.Name;
            }
            this.dxfDictionaryEntry_0.SetValue(dxfObject);
            dxfObject.Accept((IObjectVisitor)modelBuilder.ObjectCollectionResolver);
        }
        private static bool ObjectFilter_NameMatch(
            object oObj,
            object oCriteria)
        {
            string sRequiredName = (string)oCriteria;

            INamedObject oNamedObject = oObj as INamedObject;

            if (oNamedObject != null)
            {
                // Get object name
                string sName = oNamedObject.Name;

                // Check if name equals to requested
                if (StringUtil.CompareIgnoreCase(sRequiredName, sName))
                {
                    // Match
                    return(true);
                }
            }

            return(false);
        }
Exemple #30
0
        public static string GetXppSourceText(INamedObject axElement, IElementCodePositionCollector codePositionCollector, bool handleMetadataCorruptedException = true)
        {
            string result = string.Empty;

            try
            {
                if (axElement is AxClass)
                {
                    result = ((AxClass)axElement).GetCompleteSource(codePositionCollector);
                }
                else if (axElement is AxTable)
                {
                    result = ((AxTable)axElement).GetCompleteSource(codePositionCollector);
                }
                else if (axElement is AxView)
                {
                    result = ((AxView)axElement).GetCompleteSource(codePositionCollector);
                }
                else if (axElement is AxMap)
                {
                    result = ((AxMap)axElement).GetCompleteSource(codePositionCollector);
                }
                else if (axElement is AxDataEntityView)
                {
                    result = ((AxDataEntityView)axElement).GetCompleteSource(codePositionCollector);
                }
                else if (axElement is AxAggregateDataEntity)
                {
                    result = ((AxAggregateDataEntity)axElement).GetCompleteSource(codePositionCollector);
                }
                else if (axElement is AxForm)
                {
                    result = ((AxForm)axElement).GetCompleteSource(codePositionCollector);
                }
                else if (axElement is AxQuery)
                {
                    result = ((AxQuery)axElement).GetCompleteSource(codePositionCollector);
                }
                else if (axElement is AxMacroDictionary)
                {
                    result = ((AxMacroDictionary)axElement).GetCompleteSource(null);
                }
                else if (axElement is AxFormDataSourceRoot)
                {
                    result = ((AxFormDataSourceRoot)axElement).GetCompleteSource(true, null);
                }
                else if (axElement is AxFormDataSourceField)
                {
                    result = ((AxFormDataSourceField)axElement).GetCompleteSource(true, null);
                }
                else if (axElement is AxFormControl)
                {
                    result = ((AxFormControl)axElement).GetCompleteSource(true, null);
                }
            }
            catch (MetadataCorruptedException ex) when(handleMetadataCorruptedException)
            {
                AxLogHandler.DisplayError(ex.Message);
                return(string.Empty);
            }
            return(result);
        }
Exemple #31
0
 public static string GetXppSourceText(INamedObject axElement)
 {
     return(MetadataSupport.GetXppSourceText(axElement, null, true));
 }
Exemple #32
0
 public EntityPrimaryKeyExtenderTemplate(ModelRoot model, INamedObject table)
 {
     _model        = model;
     _currentTable = table;
 }
 public NamedObject(INamedObject obj)
 {
     this.Id          = obj.Id;
     this.Name        = obj.Name;
     this.DisplayText = obj.DisplayText;
 }
		public EntityPrimaryKeyExtenderTemplate(ModelRoot model, INamedObject table)
		{
			_model = model;
			_currentTable = table;
		}
		/// <summary>
		/// Returns an instance when an item was added.
		/// </summary>
		public static NamedObjectCollectionChangedEventArgs FromItemRenamed(INamedObject item, string oldName)
		{
			if (null == item)
				throw new ArgumentNullException("item");
			var result = new NamedObjectCollectionChangedEventArgs() { _item = item, _newItemName = item.Name, _oldItemName = oldName, _operation = NamedObjectCollectionChangeType.ItemRenamed };
			return result;
		}
Exemple #36
0
 public NamedEventArgs(INamedObject nameObject)
 {
     NamedObject = nameObject;
 }
 public void ValidateUniqueName(INamedObjectCollection container, INamedObject namedObject, string proposedName)
 {
     this.ValidateName(proposedName);
     if (this.NameExist(container, namedObject, proposedName))
     {
         throw new NameValidationException(System.Design.SR.GetString("CM_NameExist", new object[] { proposedName }));
     }
 }