Пример #1
0
        protected void SaveBySaveMethod(StoreContext context, object target, Type targetType)
        {
            if (target == null)
            {
                return;
            }
            var writer = context.Writer;

            var entityAttr = GetEntityAttribute(targetType);

            if (entityAttr != null && entityAttr.Save != null)
            {
                var saveMethod = targetType.GetMethod(
                    entityAttr.Save, new Type[] { typeof(IDictionary <string, string>) }
                    );
                var values = new InsertionOrderedDictionary <string, string>();
                //saveMethod.Invoke(target, new object[] { values });
                InvokeAction(target, saveMethod, values);
                writer.WriteStartElement(SaveElementName);
                SaveDictionaryProperty(
                    context, SaveElementName, values, new Type[] { typeof(string), typeof(string) }
                    );
                writer.WriteEndElement();
            }
        }
Пример #2
0
        // ------------------------------
        // private
        // ------------------------------
        private InsertionOrderedDictionary <string, KeyActionInfo <T> > CreateIdToInfos(IEnumerable <Type> types)
        {
            var ret = new InsertionOrderedDictionary <string, KeyActionInfo <T> >();

            foreach (var type in types)
            {
                var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static);
                foreach (var meth in methods)
                {
                    var paras = meth.GetParameters();
                    if (paras != null && paras.Length == 1 && paras[0].ParameterType == typeof(T))
                    {
                        var attr = Attribute.GetCustomAttribute(meth, typeof(KeyActionAttribute)) as KeyActionAttribute;
                        if (attr != null)
                        {
                            var id   = StringUtil.IsNullOrWhitespace(attr.Id) ? meth.Name : attr.Id;
                            var info = new KeyActionInfo <T>(id, attr.Description, MethodInfoUtil.ToStaticAction <T>(meth));
                            ret[id] = info;
                        }
                    }
                }
            }

            return(ret);
        }
Пример #3
0
        private IDictionary <string, object> _transientData; /// lazy

        //private string _transientId;

        // ========================================
        // constructor
        // ========================================
        public Editor()
        {
            /// Editorの親子構造の準備
            _structure = new StructuredSupport <Editor>(this);
            _structure.DetailedPropertyChanging += (sender, e) => {
                if (e.PropertyName == ICompositeProperty.Parent)
                {
                    OnParentChanging(e);
                }
                else if (e.PropertyName == ICompositeProperty.Children)
                {
                    OnChildrenChanging(e);
                }
            };
            _structure.DetailedPropertyChanged += (sender, e) => {
                if (e.PropertyName == ICompositeProperty.Parent)
                {
                    OnParentChanged(e);
                }
                else if (e.PropertyName == ICompositeProperty.Children)
                {
                    OnChildrenChanged(e);
                }
            };

            _visitable = new VisitableSupport <IEditor>(
                this,
                editor => {
                if (_structure.HasChildren)
                {
                    return(editor.Children);
                }
                else
                {
                    return(EmptyEditors);
                }
            }
                );


            _figureMaintainer = new FigureStructureMaintainer(this);

            _roles = new List <IRole>();
            _requestIdToFeedback = new Dictionary <string, IFigure>();

            _editorHandles         = new List <IEditorHandle>();
            _auxHandleToStickyKind = new InsertionOrderedDictionary <IAuxiliaryHandle, HandleStickyKind>();

            _isEnabled = false;

            _canSelect = true;
            _isFocused = false;
            _canFocus  = true;

            _isMouseEntered = false;

            //_transientId = Guid.NewGuid().ToString();
        }
Пример #4
0
        protected void SaveTypeByTypePersister(StoreContext context, string valueName, Type valueType, object value)
        {
            var writer = context.Writer;

            writer.WriteStartElement(TypeElementName);
            writer.WriteAttributeString(TypeAttributeName, valueType.FullName);
            writer.WriteAttributeString(AssemblyAttributeName, valueType.Assembly.GetName().FullName);
            {
                var values = new InsertionOrderedDictionary <string, string>();
                TypePersisters[valueType].Save(value, values);
                SaveDictionaryProperty(context, valueName, values, new Type[] { typeof(string), typeof(string) });
            }
            writer.WriteEndElement();
        }
Пример #5
0
 public void Dispose()
 {
     parent  = null;
     current = default;
 }
Пример #6
0
 public InsertionOrderedDictionaryIEnumerable(InsertionOrderedDictionary <K, V> parent)
 {
     this.parent = parent;
     Reset();
 }
Пример #7
0
 // ========================================
 // constructor
 // ========================================
 public KeyBinder(IEnumerable <Type> types)
 {
     _idToInfos = CreateIdToInfos(types);
 }