Example #1
0
        //// Events
        //public event ElementProcessedEventHandler ElementProcessed {
        //  [MethodImpl(MethodImplOptions.Synchronized)]
        //  add {
        //    this.ElementProcessedEvent = Delegate.Combine(this.ElementProcessedEvent, obj);
        //  }
        //  [MethodImpl(MethodImplOptions.Synchronized)]
        //  remove {
        //    this.ElementProcessedEvent = Delegate.Remove(this.ElementProcessedEvent, obj);
        //  }
        //}

        //public event ExceptionOccuredEventHandler ExceptionOccured {
        //  [MethodImpl(MethodImplOptions.Synchronized)]
        //  add {
        //    this.ExceptionOccuredEvent = Delegate.Combine(this.ExceptionOccuredEvent, obj);
        //  }
        //  [MethodImpl(MethodImplOptions.Synchronized)]
        //  remove {
        //    this.ExceptionOccuredEvent = Delegate.Remove(this.ExceptionOccuredEvent, obj);
        //  }
        //}

        // Methods
        protected override void OnElement(CGMElement el)
        {
            try
            {
                if ((el.ElementClass == 1) && (el.ElementId == 12))
                {
                    MemoryStream r = new MemoryStream(el.Data, false);
                    CGMScanner.ReadFile(r, this);
                }
                else
                {
                    using (CGMBinaryReader reader = this.GetReader(el))
                    {
                        [email protected] = reader;
                        [email protected](el);
                        this.elementlist.Add(ElementDictionary.GetInstance().FindElement(el.ElementClass, el.ElementId) + " " + el.ElementId.ToString() + " : " + el.ElementClass.ToString());
                        if (this.ElementProcessedEvent != null)
                        {
                            this.ElementProcessedEvent(el);
                        }
                    }
                }
            }
            catch (Exception exception1)
            {
                //ProjectData.SetProjectError(exception1);
                Exception ex = exception1;
                if (this.ExceptionOccuredEvent != null)
                {
                    this.ExceptionOccuredEvent(el, ex);
                }
                //ProjectData.ClearProjectError();
            }
        }
Example #2
0
 void  OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         elementDictionary = AssetDatabase.LoadAssetAtPath(objectPath, typeof(ElementDictionary)) as ElementDictionary;
     }
 }
Example #3
0
        /// <summary>
        /// Fine element definition with same path (except for first part)
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool TryFindMatch(ElementDefinition e, out ElementDefinition match)
        {
            if (e is null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            String uniquePath = ElementDictionary.UniquePath(e);

            return(this.elementDictionary.TryGetValue(uniquePath, out match));
        }
Example #4
0
        ///////////////////////////////////////////////////////////////////////

        public void Reset(
            EventWaitHandle @event
            )
        {
            flags         = VariableFlags.None;
            qualifiedName = null;
            link          = null;
            linkIndex     = null;
            value         = null;
            arrayValue    = null;
            traces        = null; // BUGBUG: Is this correct (i.e. does Tcl do this)?
            this.@event   = @event;
        }
Example #5
0
 void CreateNewItemList()
 {
     // There is no overwrite protection here!
     // There is No "Are you sure you want to overwrite your existing object?" if it exists.
     // This should probably get a string from the user to create a new name and pass it ...
     viewIndex         = 1;
     elementDictionary = CreateElementDictionary.Create();
     if (elementDictionary)
     {
         elementDictionary.allElements = new List <Element>();
         string relPath = AssetDatabase.GetAssetPath(elementDictionary);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Example #6
0
        /// <summary>
        /// Fine element definition with same path (except for first part)
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public void Add(ElementDefinition e)
        {
            if (e is null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            String path = ElementDictionary.UniquePath(e);

            if (path == null)
            {
                throw new Exception($"Invalid path for elemend {e.ElementId}");
            }

            elementDictionary.Add(path, e);
        }
Example #7
0
 public ComponentGeometry(Array elementTypes)
 {
     positions_      = new ArrayDictionary();
     mapNodeNames    = new StringDictionary();
     nodeNames       = new ArrayDictionary();
     nodeAngles      = new ArrayDictionary();
     nodeCoordinates = new ArrayDictionary();
     elementData     = new ElementDictionary();
     vertices        = new ArrayDictionary();
     normals         = new ArrayDictionary();
     foreach (ElementType type in elementTypes)
     {
         elementData.Add(type, new Dictionary <string, Array>());
     }
     colors = new ColorDictionary();
 }
Example #8
0
    void OpenItemList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Element Dictionary", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            elementDictionary = AssetDatabase.LoadAssetAtPath(relPath, typeof(ElementDictionary)) as ElementDictionary;
            if (elementDictionary.allElements == null)
            {
                elementDictionary.allElements = new List <Element>();
            }
            if (elementDictionary)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }
    public static ElementDictionary Create()
    {
        ElementDictionary asset = ScriptableObject.CreateInstance <ElementDictionary>();

        Object[] allDictionary = Resources.LoadAll("ScriptObjects/Dictionary", typeof(ElementDictionary));
        counter = allDictionary.Length + 1;

        if (counter == 1)
        {
            AssetDatabase.CreateAsset(asset, "Assets/Resources/ScriptObjects/Dictionary/ElementDictionary.asset");
        }
        else
        {
            AssetDatabase.CreateAsset(asset, "Assets/Resources/ScriptObjects/Dictionary/ElementDictionary" + counter + ".asset");
        }
        counter++;
        AssetDatabase.SaveAssets();
        return(asset);
    }
Example #10
0
        ///////////////////////////////////////////////////////////////////////

        internal TraceInfo(
            ITrace trace,
            BreakpointType breakpointType,
            ICallFrame frame,
            IVariable variable,
            string name,
            string index,
            VariableFlags flags,
            object oldValue,
            object newValue,
            ElementDictionary oldValues,
            ElementDictionary newValues,
            StringList list,
            bool cancel,
            bool postProcess,
            ReturnCode returnCode
            )
        {
            Update(
                trace, breakpointType, frame, variable, name, index, flags,
                oldValue, newValue, oldValues, newValues, list, cancel,
                postProcess, returnCode);
        }
Example #11
0
        ///////////////////////////////////////////////////////////////////////

        public ITraceInfo Update(
            ITrace trace,
            BreakpointType breakpointType,
            ICallFrame frame,
            IVariable variable,
            string name,
            string index,
            VariableFlags flags,
            object oldValue,
            object newValue,
            ElementDictionary oldValues,
            ElementDictionary newValues,
            StringList list,
            bool cancel,
            bool postProcess,
            ReturnCode returnCode
            )
        {
            this.trace          = trace;
            this.breakpointType = breakpointType;
            this.frame          = frame;
            this.variable       = variable;
            this.name           = name;
            this.index          = index;
            this.flags          = flags;
            this.oldValue       = oldValue;
            this.newValue       = newValue;
            this.oldValues      = oldValues;
            this.newValues      = newValues;
            this.list           = list;
            this.cancel         = cancel;
            this.postProcess    = postProcess;
            this.returnCode     = returnCode;

            return(this);
        }
Example #12
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        #region IEnumerable Members
        public IEnumerator GetEnumerator()
        {
            //
            // NOTE: Make sure that the variable they supplied is valid before we try to
            //       use it as the basis of our enumerator.
            //
            if (interpreter != null)
            {
                //
                // HACK: Handle the global "env" array specially.  We must do this because
                //       our global "env" array has no backing storage (unlike Tcl's) and
                //       we do not have a trace operation for "get names" or "get names
                //       and values".
                //
                if (interpreter.IsEnvironmentVariable(variable))
                {
                    IDictionary environment =
                        Environment.GetEnvironmentVariables();

                    if (environment != null)
                    {
                        return(environment.Keys.GetEnumerator());
                    }
                    else
                    {
                        DebugOps.Complain(interpreter, ReturnCode.Error,
                                          "environment variables unavailable");
                    }
                }
                else if (interpreter.IsTestsVariable(variable))
                {
                    Result           error = null;
                    StringDictionary tests = interpreter.GetAllTestInformation(
                        false, ref error);

                    if (tests != null)
                    {
                        return((IEnumerator)tests.Keys.GetEnumerator());
                    }
                    else
                    {
                        DebugOps.Complain(interpreter, ReturnCode.Error, error);
                    }
                }
                else if (interpreter.IsSystemArrayVariable(variable))
                {
                    ReturnCode code;
                    StringList keys  = null;
                    Result     error = null;

                    code = MarshalOps.GetArrayElementKeys(
                        interpreter, EntityOps.GetSystemArray(variable),
                        StringOps.DefaultMatchMode, null, false, ref keys,
                        ref error);

                    if (code == ReturnCode.Ok)
                    {
                        return(keys.GetEnumerator());
                    }
                    else
                    {
                        DebugOps.Complain(interpreter, code, error);
                    }
                }
                else
                {
#if DATA
                    DatabaseVariable databaseVariable = null;

                    if (interpreter.IsDatabaseVariable(variable, ref databaseVariable))
                    {
                        Result error = null;

                        ObjectDictionary database = databaseVariable.GetList(
                            interpreter, true, false, ref error);

                        if (database != null)
                        {
                            return((IEnumerator)database.Keys.GetEnumerator());
                        }
                        else
                        {
                            DebugOps.Complain(interpreter, ReturnCode.Error, error);
                        }
                    }
                    else
#endif
                    {
                        if (variable != null)
                        {
                            ElementDictionary arrayValue = variable.ArrayValue;

                            if ((arrayValue != null) && (arrayValue.Keys != null))
                            {
                                return(arrayValue.Keys.GetEnumerator());
                            }
                        }
                    }
                }
            }

            //
            // NOTE: While the MSDN documentation does not seem to prohibit returning
            //       null here, there may be components and/or applications that would
            //       consider it "bad form"; therefore, we simply return an enumerator
            //       that does nothing.
            //
            return(new NullEnumerator <object>());
        }
Example #13
0
        ///////////////////////////////////////////////////////////////////////

        public StringPairList ToStringPairList()
        {
            StringPairList result = new StringPairList();

            if (variable != null)
            {
                result.Add(variable.Kind.ToString());
                result.Add((IPair <string>)null);

                if (variable.Name != null)
                {
                    result.Add("name", variable.Name);
                }
                else
                {
                    result.Add("name", String.Empty);
                }

                if (EntityOps.IsArray2(variable))
                {
                    ElementDictionary arrayValue = variable.ArrayValue;

                    if (arrayValue != null)
                    {
                        result.Add("<array>");

                        if (index != null)
                        {
                            object value;

                            if (arrayValue.TryGetValue(index, out value))
                            {
                                if (value != null)
                                {
                                    result.Add("value",
                                               StringOps.GetStringFromObject(
                                                   value, null, !(value is TraceInfo)));
                                }
                                else
                                {
                                    result.Add("value", FormatOps.DisplayNull);
                                }
                            }
                            else
                            {
                                result.Add("value", "<noValue>");
                            }
                        }
                        else
                        {
                            result.Add("value", "<noIndex>");
                        }
                    }
                    else
                    {
                        result.Add("<noArray>");
                    }
                }
                else
                {
                    object value = variable.Value;

                    if (value != null)
                    {
                        result.Add("value",
                                   StringOps.GetStringFromObject(value));
                    }
                    else
                    {
                        result.Add("value", "<noValue>");
                    }
                }

                result.Add("flags", variable.Flags.ToString());
                result.Add((IPair <string>)null);
            }

            result.Add("TraceInfo");
            result.Add((IPair <string>)null);

            if (trace != null)
            {
                result.Add("trace", trace.ToString());
            }
            else
            {
                result.Add("trace", "<noTrace>");
            }

            result.Add("breakpointType", breakpointType.ToString());

            if (frame != null)
            {
                result.Add("frame", (frame.Name != null) ?
                           frame.Name : "<noFrameName>");
            }
            else
            {
                result.Add("frame", "<noFrame>");
            }

            if (name != null)
            {
                result.Add("name", name);
            }
            else
            {
                result.Add("name", "<noName>");
            }

            if (index != null)
            {
                result.Add("index", index);
            }
            else
            {
                result.Add("index", "<noIndex>");
            }

            result.Add("flags", flags.ToString());

            if (oldValue != null)
            {
                result.Add("oldValue",
                           StringOps.GetStringFromObject(oldValue));
            }
            else
            {
                result.Add("oldValue", "<noOldValue>");
            }

            if (newValue != null)
            {
                result.Add("newValue",
                           StringOps.GetStringFromObject(newValue));
            }
            else
            {
                result.Add("newValue", "<noNewValue>");
            }

            if (oldValues != null)
            {
                result.Add("oldValues", oldValues.ToString());
            }
            else
            {
                result.Add("oldValues", "<noOldValues>");
            }

            if (newValues != null)
            {
                result.Add("newValues", newValues.ToString());
            }
            else
            {
                result.Add("newValues", "<noNewValues>");
            }

            if (list != null)
            {
                result.Add("list", list.ToString());
            }
            else
            {
                result.Add("list", "<noList>");
            }

            result.Add("cancel", cancel.ToString());
            result.Add("postProcess", postProcess.ToString());
            result.Add("returnCode", returnCode.ToString());

            return(result);
        }
Example #14
0
        /// <summary>
        /// Validates the target.
        /// </summary>
        /// <param name="temp">The temporary.</param>
        /// <param name="current">The current.</param>
        /// <param name="rdr">The RDR.</param>
        /// <param name="mappings">The mappings.</param>
        /// <param name="session">The session.</param>
        /// <returns></returns>
        private ValidationStatus ValidateTarget(object temp, int current, IDataReader rdr,
                                                IDictionary <string, string> mappings, IStatelessSession session)
        {
            //bool hasError = false;
            var validationResult = ValidationEngine.ValidateInstance(temp);
            // var updateCount = validationResult.PropertyErrors.Count + validationResult.PropertyWarnings.Count;
            bool hasError = validationResult.PropertyErrors.Any() || validationResult.ClassErrors.Any();

            if (validationResult.ClassErrors.Any())
            {
                hasError = true;
                foreach (var res in validationResult.ClassErrors)
                {
                    string member = string.Empty;
                    string msg    = null;
                    object value  = null;
                    if (res.Property != null)
                    {
                        member = res.Property.Name;

                        if (mappings.ContainsKey(member))
                        {
                            var column = mappings[member];
                            var ord    = rdr.GetOrdinal(column);
                            value = rdr.GetValue(ord);
                            msg   = string.Format("Value excluded: {0}",
                                                  value == null
                                    ? "<<NULL>>"
                                    : string.IsNullOrEmpty(value.ToString())
                                        ? @""""
                                        : value.ToString());
                        }
                    }


                    if (res.ErrorState == ValidationErrorState.ValidationError && !string.IsNullOrEmpty(res.Message))
                    {
                        msg = string.Format("{1} (Value excluded: {0})",
                                            (value == null
                               ? "<<NULL>>"
                               : string.IsNullOrEmpty(value.ToString()) ? @"""" : value.ToString()),
                                            res.Message);
                    }

                    if (res.ErrorState == ValidationErrorState.ValidationError && !string.IsNullOrEmpty(res.Message))
                    {
                        member = "Row Level";
                        msg    = res.Message;
                    }

                    GuardError(member, msg, current, res.ErrorState == ValidationErrorState.ExcludedByCrosswalk ? RecordState.ExcludedByCrosswalk : RecordState.ValidationError, session); //RecordState.ExcludedByCrosswalk
                }
            }

            if (validationResult.PropertyErrors.Any())
            {
                // updateCount += validationResult.PropertyErrors.Count;
                hasError = true;
                foreach (var err in validationResult.PropertyErrors.ToList())
                {
                    Element elemTest;
                    ElementDictionary.TryGetValue(err.Property.Name.ToLower(), out elemTest);
                    if (elemTest != null)
                    {
                        GuardError(elemTest.Description,
                                   ElementMappingModel.ParseValueError(err.AttemptedValue, err.Message),
                                   current, RecordState.ValidationError, session);
                    }
                }
            }
            if (validationResult.PropertyWarnings.Any())
            {
                foreach (var err in validationResult.PropertyWarnings)
                {
                    Element elemTest;
                    ElementDictionary.TryGetValue(err.Property.Name.ToLower(), out elemTest);
                    if (elemTest != null)
                    {
                        GuardError(elemTest.Description,
                                   ElementMappingModel.ParseValueError(err.AttemptedValue, err.Message),
                                   current, RecordState.Warning, session);
                    }
                }
            }


            var result = new ValidationStatus();

            result.HasErrors = hasError;
            return(result);
        }
        /// <summary>
        /// Validates the target.
        /// </summary>
        /// <param name="temp">The temporary.</param>
        /// <param name="current">The current.</param>
        /// <param name="rdr">The RDR.</param>
        /// <param name="mappings">The mappings.</param>
        /// <param name="session">The session.</param>
        /// <returns></returns>
        private ValidationStatus ValidateTarget(object temp, int current, IDataReader rdr,
                                                IDictionary <string, string> mappings, IStatelessSession session)
        {
            bool hasError         = false;
            var  validationResult = ValidationEngine.ValidateInstance(temp);
            var  updateCount      = validationResult.PropertyErrors.Count + validationResult.PropertyWarnings.Count;

            hasError = validationResult.PropertyErrors.Any() || validationResult.ClassErrors.Any();

            if (validationResult.ClassErrors.Any())
            {
                updateCount += validationResult.ClassErrors.Count;
                hasError     = true;

                foreach (var res in validationResult.ClassErrors)
                {
                    string member = string.Empty;
                    string msg    = null;
                    object value  = null;

                    if (res.Property != null)
                    {
                        member = res.Property.Name;
                        var column = mappings[member];
                        var ord    = rdr.GetOrdinal(column);
                        value = rdr.GetValue(ord);
                        msg   = string.Format("Value excluded: {0}",
                                              value == null
                                ? "<<NULL>>"
                                : string.IsNullOrEmpty(value.ToString())
                                    ? @""""
                                    : value.ToString());
                    }

                    if (res.ErrorState == ValidationErrorState.ValidationError && !string.IsNullOrEmpty(res.Message))
                    {
                        msg = string.Format("{1} (Value excluded: {0})",
                                            (value == null
                               ? "<<NULL>>"
                               : string.IsNullOrEmpty(value.ToString()) ? @"""" : value.ToString()),
                                            res.Message);
                    }

                    GuardError(member, msg, current, RecordState.ExcludedByCrosswalk, session);
                    //TODO: Output messages to screen, other log file per import, someplace besited the main session.log
                    //this.DataContextObject.Logger.Write(string.Format(VALIDATION_LOG_MESSAGE, DataContextObject.SelectedDataType.DataTypeName, DataContextObject.Title, "Class Error", msg), Category.Info, Priority.High);
                }
            }

            if (validationResult.PropertyErrors.Any())
            {
                hasError = true;

                foreach (var err in validationResult.PropertyErrors)
                {
                    Element elemTest;
                    ElementDictionary.TryGetValue(err.Property.Name.ToLower(), out elemTest);
                    if (elemTest != null)
                    {
                        GuardError(elemTest.Description,
                                   ElementMappingModel.ParseValueError(err.AttemptedValue, err.Message),
                                   current, RecordState.ValidationError, session);
                    }
                    //TODO: Output messages to screen, other log file per import, someplace besited the main session.log
                    //this.DataContextObject.Logger.Write(string.Format(VALIDATION_LOG_MESSAGE, DataContextObject.SelectedDataType.DataTypeName, DataContextObject.Title, "Error", err.Message), Category.Info, Priority.High);
                }
            }

            if (validationResult.PropertyWarnings.Any())
            {
                foreach (var err in validationResult.PropertyWarnings)
                {
                    Element elemTest;
                    ElementDictionary.TryGetValue(err.Property.Name.ToLower(), out elemTest);
                    if (elemTest != null)
                    {
                        GuardError(elemTest.Description,
                                   ElementMappingModel.ParseValueError(err.AttemptedValue, err.Message),
                                   current, RecordState.Warning, session);
                    }
                    //TODO: Output messages to screen, other log file per import, someplace besited the main session.log
                    //this.DataContextObject.Logger.Write(string.Format(VALIDATION_LOG_MESSAGE, DataContextObject.SelectedDataType.DataTypeName, DataContextObject.Title, "Warning", err.Message), Category.Info, Priority.High);
                }
            }


            var result = new ValidationStatus();

            result.HasErrors = hasError;
            return(result);
        }
Example #16
0
        ///////////////////////////////////////////////////////////////////////

        public void SetupValue(
            object newValue,
            bool union,
            bool array,
            bool clear,
            bool flag
            )
        {
            if (array)
            {
                //
                // NOTE: An array variable cannot have a scalar value unless
                //       the caller specifically asks for one.
                //
                if (union && (value != null))
                {
                    value = null;
                }
                else if (newValue != null)
                {
                    value = newValue;
                }

                //
                // NOTE: An array variable must have an array value (element
                //       dictionary).  Only clear it if requested by the
                //       caller.
                //
                if (arrayValue == null)
                {
                    arrayValue = new ElementDictionary(@event);
                }
                else if (clear)
                {
                    arrayValue.Clear();
                }

                //
                // NOTE: Set the array flag?
                //
                if (flag)
                {
                    flags |= VariableFlags.Array;
                }
            }
            else
            {
                //
                // NOTE: A scalar variable cannot have an array value (element
                //       dictionary).
                //
                if (union && (arrayValue != null))
                {
                    arrayValue = null;
                }

                //
                // NOTE: A scalar variable can have a scalar value.  Only clear
                //       it if requested by the caller.  Otherwise, set the new
                //       value if requested by the caller.
                //
                if (clear)
                {
                    value = null;
                }
                else if (newValue != null)
                {
                    value = newValue;
                }

                //
                // NOTE: Unset the array flag?
                //
                if (flag)
                {
                    flags &= ~VariableFlags.Array;
                }
            }
        }
Example #17
0
        public void ElementWrite(CGMElement element)
        {
            bool flag = false;

            try
            {
                switch (element.ElementClass)
                {
                case 0:
                    flag = EClass0.class0(element, this.mycontext, this.myxml);
                    return;

                case 1:
                    flag = EClass1.class1(element, this.mycontext, this.myxml);
                    return;

                case 2:
                    flag = EClass2.class2(element, this.mycontext, this.myxml);
                    return;

                case 3:
                    flag = EClass3.class3(element, this.mycontext, this.myxml);
                    return;

                case 4:
                    flag = EClass4.class4(element, this.mycontext, this.myxml);
                    return;

                case 5:
                    flag = EClass5.class5(element, this.mycontext, this.myxml);
                    return;

                case 6:
                case 8:
                    return;

                case 7:
                    flag = EClass6.class7(element, this.mycontext, this.myxml);
                    return;

                case 9:
                    break;

                default:
                    return;
                }
                flag = EClass6.class9(element, this.mycontext, this.myxml);
            }
            catch (Exception exception1)
            {
                //ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                if (exception.Message == "Invalid Use.")//if (StringType.StrCmp(exception.Message, "Invalid Use.", false) == 0)
                {
                    throw new Exception("This conversion is being called from an invalid source, Please contract Docsoft Inc. if the probem continues.");
                }
                throw new Exception(element.ElementClass.ToString() + " " + element.ElementId.ToString() + " - " + ElementDictionary.GetInstance().FindElement(element.ElementClass, element.ElementId) + " - " + exception.ToString());
            }
        }