public Main() { InitializeComponent(); _sourceFiles = new FileList<FileData>(); _extensions = new ExtensionList<ExtensionData>("C:\\sets.xml"); gridDestinations.RowTemplate.Height = Util.ColHeight; gridDestinations.CellValueChanged += OnCellvalueChanged; clmnCheckBox.DataPropertyName = "Checked"; clmnFileName.DataPropertyName = "FileName"; clmnExt.DataPropertyName = "Extension"; clmnSourcePath.DataPropertyName = "FullPath"; clmnDestPath.DataPropertyName = "DestinationPath"; gridFiles.DataSource = _sourceFiles; clmnID.DataPropertyName = "Id"; clmnExtension.DataPropertyName = "Extension"; clmnDestFolder.DataPropertyName = "FullPath"; gridDestinations.DataSource = _extensions; RefreshButtonsCaption(); }
public void Add(byte code, byte[] val) { ExtensionList elem = new ExtensionList(code, (byte)val.Length, val); ExtensionList.tail.previous.next = elem; ExtensionList.tail.previous = elem; }
private void OnAddExtension() { if (!string.IsNullOrEmpty(ComboBoxText) && !ExtensionList.Contains(ComboBoxText)) { ExtensionList.Add(ComboBoxText); } }
public async Task <Response <ExtensionList> > ListByArcSettingAsync(string subscriptionId, string resourceGroupName, string clusterName, string arcSettingName, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (clusterName == null) { throw new ArgumentNullException(nameof(clusterName)); } if (arcSettingName == null) { throw new ArgumentNullException(nameof(arcSettingName)); } using var message = CreateListByArcSettingRequest(subscriptionId, resourceGroupName, clusterName, arcSettingName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { ExtensionList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = ExtensionList.DeserializeExtensionList(document.RootElement); return(Response.FromValue(value, message.Response)); }
public override bool IsValid(object value) { //http://stackoverflow.com/questions/422090/in-c-sharp-check-that-filename-is-possibly-valid-not-that-it-exists var fileName = (string)value; if (string.IsNullOrEmpty(fileName)) { return(true); } //responsibility of RequiredAttribute if (fileName.IndexOfAny(Path.GetInvalidFileNameChars()) > -1 || (!AllowHidden && fileName[0] == '.') || fileName[fileName.Length - 1] == '.') { return(false); } FileInfo fi = null; try { fi = new FileInfo(fileName); } catch (ArgumentException) { } catch (PathTooLongException) { } catch (NotSupportedException) { } return(fi != null && (!RequireExtension || fi.Extension != string.Empty) && (ExtensionList == null || ExtensionList.Contains(fi.Extension))); }
/// <summary> /// Fluent settings result /// </summary> /// <returns></returns> public ExtensionList Map() { var result = new ExtensionList(); this.MapTo(result); return(result); }
public void PopulateITHeadMasters(List <ITHeadMaster> headList, List <ITSubHeadMaster> subHeadList, int?itreturnId) { this.ITHeadMasterList = new Dictionary <string, ITHeadMaster>(); foreach (var item in headList) { item.SubHeadList = subHeadList.Where(sh => sh.ITHeadId == item.Id) .ToList <ITSubHeadMaster>(); if (!this.ITHeadMasterList.ContainsKey(item.PropertyName)) { this.ITHeadMasterList.Add(item.PropertyName, item); } foreach (var subItem in item.SubHeadList) { ExtensionList.Add(new ITReturnDetailsExtension { ITSubHeadId = subItem.Id, SubHeadMasterObject = subItem, HeadMasterObject = item, ITReturnDetailsId = itreturnId.HasValue ? itreturnId.Value : 0, IsAllowance = subItem.IsAllowance.HasValue ? subItem.IsAllowance.Value : false }); } } }
private void OnRemoveExtension() { if (!string.IsNullOrEmpty(ComboBoxText) && ExtensionList.Contains(ComboBoxText)) { ExtensionList.Remove(ComboBoxText); } }
public SqlTable([JetBrains.Annotations.NotNull] MappingSchema mappingSchema, ExtensionList extensions, string name) : this() { if (mappingSchema == null) { throw new ArgumentNullException("mappingSchema"); } if (extensions == null) { throw new ArgumentNullException("extensions"); } if (name == null) { throw new ArgumentNullException("name"); } var te = extensions[name]; if (te == TypeExtension.Null) { throw new ArgumentException(string.Format("Table '{0}' not found.", name)); } Name = te.Name; Alias = (string)te.Attributes["Alias"].Value; Database = (string)te.Attributes["Database"].Value; Owner = (string)te.Attributes["Owner"].Value; PhysicalName = (string)te.Attributes["PhysicalName"].Value ?? te.Name; foreach (var me in te.Members.Values) { Fields.Add(new SqlField( (Type)me["Type"].Value, me.Name, (string)me["MapField"].Value ?? (string)me["PhysicalName"].Value, (bool?)me["Nullable"].Value ?? false, -1, (bool?)me["Identity"].Value == true ? new IdentityAttribute() : null, null)); } foreach (var ae in te.Attributes["Join"]) { Joins.Add(new Join(ae)); } var baseExtension = (string)te.Attributes["BaseExtension"].Value; if (!string.IsNullOrEmpty(baseExtension)) { InitFromBase(new SqlTable(mappingSchema, extensions, baseExtension)); } var baseTypeName = (string)te.Attributes["BaseType"].Value; if (!string.IsNullOrEmpty(baseTypeName)) { InitFromBase(new SqlTable(mappingSchema, Type.GetType(baseTypeName, true, true))); } }
public virtual string GetTableName(Type type, ExtensionList extensions, out bool isSet) { isSet = false; return (type.IsInterface && type.Name.StartsWith("I") ? type.Name.Substring(1) : type.Name); }
public static void GetMinCapacityTest() { var instance = new ExtensionList(); var maxCapacity = instance.GetMinCapacity(); // 取得した値が容量最大値と一致すること Assert.AreEqual(maxCapacity, ExtensionList.MinCapacity); }
/// <summary> /// Closes the module. /// </summary> /// <remarks>Documented by Dev08, 2009-07-15</remarks> private void CloseModule() { SettingsManagerLogic.CloseLearningModule(); TreeViewItems.Clear(); treeViewLearningModule.ItemsSource = null; ExtensionList.Clear(); EnableControls(false); }
public static void SerializeTest() { var target = new ExtensionList(new List <Extension> { ".A", ".B", "CCC" }); var clone = DeepCloner.DeepClone(target); Assert.IsTrue(clone.Equals(target)); }
public void MapingFromType(Type T) { var res = new ExtensionList(); var map = (IFluentMap)Activator.CreateInstance(T); map.MapTo(res); FluentMapHelper.MergeExtensions(res, ref this._extensions); }
protected void RemoveItem() { var index = DisplayFileInfoList.IndexOf(SelectedFileInfo); FileInfoList.Remove(SelectedFileInfo); DisplayFileInfoList.Remove(SelectedFileInfo); //選択アイテムの更新 if (DisplayFileInfoList.Count == 0) { //表示対象がない index = -1; } else if (DisplayFileInfoList.Count <= index) { index = DisplayFileInfoList.Count - 1; } else { //何もしない } if (index >= 0) { DisplayFileInfoList.ElementAt(index).IsSelected = true; } //フィルタの更新 var missingKeywordList = new List <Extension>(); foreach (var item in ExtensionList) { missingKeywordList.Add(item); } missingKeywordList.RemoveAt(0); foreach (var item in DisplayFileInfoList) { var extension = Path.GetExtension(item.FilePath); var extensionItems = ExtensionList.Where(x => x.Name == extension); if (extensionItems.Any()) { foreach (var extItem in extensionItems) { missingKeywordList.Remove(extItem); } } } foreach (var item in missingKeywordList) { ExtensionList.Remove(item); } HasItem = FileInfoList.Any(); }
/// <summary> /// all extension element factories that match a namespace/localname /// given will be removed and the new one will be inserted /// </summary> /// <param name="localName">the local name to find</param> /// <param name="ns">the namespace to match, if null, ns is ignored</param> /// <param name="obj">the new element to put in</param> public void ReplaceFactory(string localName, string ns, IExtensionElementFactory obj) { ExtensionList arr = Utilities.FindExtensions(this.ExtensionFactories, localName, ns, new ExtensionList(this)); foreach (IExtensionElementFactory ob in arr) { this.ExtensionFactories.Remove(ob); } this.ExtensionFactories.Add(obj); }
protected override void ProcessResource(ExtensionList aExtensions) { var document = LoadXml(Filenames.ExtensionsUsed + ".xml"); if (document != null) { aExtensions.Names.AddRange(from element in document.Elements("Name") select element.Value); } }
/////////////////////////////////////////////////////////////////////// /// <summary>Removes all Google Base attributes.</summary> /////////////////////////////////////////////////////////////////////// public void Clear() { ExtensionList toRemove = ExtensionList.NotVersionAware(); foreach (GBaseAttribute attribute in this) { toRemove.Add(attribute); } RemoveAll(toRemove); }
public void ShouldConfigMapping() { ExtensionList extensions = new ExtensionList(); FluentConfig.Configure(extensions) .MapingFromAssemblyOf <FluentConfigTest>(); Assert.IsTrue(extensions.ContainsKey(typeof(Dbo1).FullName), "Not mapping"); Assert.IsFalse(extensions.ContainsKey(typeof(Dbo2).FullName), "Fail mapping for abstract"); Assert.IsFalse(extensions.ContainsKey(typeof(Dbo3).FullName), "Fail mapping for generic"); }
/** ======================================== * EditorIniオブジェクト作成 * ======================================== */ public static EditorIniData GenerateData0() { return(new EditorIniData { StartFlag = 0, LastLoadFile = "MapData/Map000.mps", MainWindowPosition = (0, 0), MainWindowSize = (651, 322), MapChipWindowPosition = (0, 0), MapEventWindowPosition = (273, 230), MapEventWindowSize = (840, 410), MapEventInputWindowPosition = (0, 0), CommonEventWindowPosition = (0, 0), CommonEventWindowSize = (800, 640), CommonEventInputWindowPosition = (0, 0), UserDbWindowPosition = (27, 54), ChangeableDbWindowPosition = (27, 54), SystemDbWindowPosition = (27, 54), DatabaseValueNumberDrawType = DatabaseValueNumberDrawType.FromCode("0"), EditTimeDrawType = EditTimeDrawType.On, EditTime = 14, NotEditTime = 0, IsShowDebugWindow = true, LayerTransparent = LaterTransparentType.FromCode("2"), EventLayerOpacity = EventLayerOpacityType.FromCode("1"), CommandColorType = CommandColorType.FromCode("0"), IsDrawBackgroundImage = true, NotCopyExtList = new ExtensionList(new Extension[] { ".psd", ".sai", ".svg", ".xls", ".db", ".tmp", ".bak", ".db", "dummy_file" }), CommandViewType = 0, BackupType = ProjectBackupType.FromCode("3"), ShortCutKeyList = new EventCommandShortCutKeyList(new[] { EventCommandShortCutKey.One, EventCommandShortCutKey.Two, EventCommandShortCutKey.Three, EventCommandShortCutKey.Four, EventCommandShortCutKey.Five, EventCommandShortCutKey.Six, EventCommandShortCutKey.Seven, EventCommandShortCutKey.Eight, EventCommandShortCutKey.Nine, EventCommandShortCutKey.A, EventCommandShortCutKey.B, EventCommandShortCutKey.C, EventCommandShortCutKey.D, EventCommandShortCutKey.E, EventCommandShortCutKey.F, EventCommandShortCutKey.G, EventCommandShortCutKey.H, EventCommandShortCutKey.I, EventCommandShortCutKey.J, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, EventCommandShortCutKey.One, }), CommandPositionList = new ShortCutPositionList(new ShortCutPosition[] { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 17, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, }), IsUseExpertCommand = false, });
/// <summary> /// Delete's all Extensions from the Extension list that match /// a localName and a Namespace. /// </summary> /// <param name="localName">the local name to find</param> /// <param name="ns">the namespace to match, if null, ns is ignored</param> /// <returns>int - the number of deleted extensions</returns> public int DeleteExtensions(string localName, string ns) { // Find them first ExtensionList arr = FindExtensions(localName, ns); foreach (IExtensionElementFactory ob in arr) { this.extensions.Remove(ob); } return(arr.Count); }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { var tblAttrs = TypeHelper.GetAttributes(type, typeof(TableAttribute)); if (tblAttrs != null && tblAttrs.Length > 0) { string name = ((TableAttribute)tblAttrs[0]).Name; isSet = !string.IsNullOrEmpty(name); return(name); } return(base.GetTableName(type, extensions, out isSet)); }
public DiskSettings() { this.DiskSpaceSize = new Exceptable <long>(1024 * 1024 * 1024); this.EnableDisk = true; this.MaxFileCount = new Exceptable <int>(0); this.MaxFileSize = new Exceptable <long>(10 * 1024 * 1024); this.PackZip = new Exceptable <bool>(true); this.UnpackRar = new Exceptable <bool>(true); this.UnpackZip = new Exceptable <bool>(true); this.AllowFileExtensions = new Exceptable <ExtensionList>(ExtensionList.Parse("*")); this.DefaultViewMode = new Exceptable <FileViewMode>(FileViewMode.Thumbnail); }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { object[] attrs = type.GetCustomAttributes(typeof(TableNameAttribute), true); if (attrs.Length > 0) { isSet = true; return(((TableNameAttribute)attrs[0]).Name); } return(base.GetTableName(type, extensions, out isSet)); }
/// <summary> /// takes the base object, and the localname/ns combo to look for /// will copy objects to an internal array for caching. Note that when the external /// ExtensionList is modified, this will have no effect on this copy /// </summary> /// <param name="containerElement">the base element holding the extension list</param> /// <param name="localName">the local name of the extension</param> /// <param name="ns">the namespace</param> public ExtensionCollection(IExtensionContainer containerElement, string localName, string ns) : base() { this.container = containerElement; if (this.container != null) { ExtensionList arr = this.container.FindExtensions(localName, ns); foreach (T o in arr) { _items.Add(o); } } }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { var typeExt = TypeExtension.GetTypeExtension(type, extensions); var value = typeExt.Attributes["TableName"].Value; if (value != null) { isSet = true; return(value.ToString()); } return(base.GetTableName(type, extensions, out isSet)); }
private ExtensionList GetAttributeList(string name, GBaseAttributeType type) { ExtensionList retval = ExtensionList.NotVersionAware(); foreach (GBaseAttribute attribute in this) { if (HasNameAndType(attribute, name, type)) { retval.Add(attribute); } } return(retval); }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { if (IsLinqObject(type)) { isSet = true; var attrs = type.GetCustomAttributes(typeof(TableAttribute), true); return(((TableAttribute)attrs[0]).Name); } return(base.GetTableName(type, extensions, out isSet)); }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { var attrs = type.GetCustomAttributes(typeof(TableNameAttribute), true); if (attrs.Length > 0) { var name = ((TableNameAttribute)attrs[0]).Name; isSet = name != null; return(name); } return(base.GetTableName(type, extensions, out isSet)); }
protected ExtensionList FilterFileType(ExtensionList filetypes) { ExtensionList ext = new ExtensionList(); foreach (string s in filetypes) { if (ForumAllowedFileTypes.Contains(s)) { ext.Add(s); } } return(ext); }
private ExtensionList GetAttributeList(string name) { ExtensionList retval = ExtensionList.NotVersionAware(); foreach (GBaseAttribute attribute in this) { if (name == attribute.Name) { retval.Add(attribute); } } return(retval); }
private static bool AddExtensionToResult(byte[] buffer, ref int currentLen, Int16 extLen, ConnectionEnd end, ExtensionList knownExtensions, ExtensionType type, ref ExtensionList result) { foreach (var extension in knownExtensions) { if (extension.Type == type) { result.Add(extension.Parse(buffer, ref currentLen, extLen, end)); return true; } } return false; }
public AudioScanner(IDataParser parser, DirectoryInfo directory, SearchOption searchoption, params string[] extensions) { if (parser == null) throw new ArgumentNullException("parser"); if (directory == null) throw new ArgumentNullException("directory"); _parser = parser; _directory = directory; _searchoption = searchoption; _extensionList = new ExtensionList(extensions); MediaLibrary = new Library(); }
public static ExtensionList Parse(byte[] buffer, ref int currentLen, ExtensionList knownExtensions, ConnectionEnd end) { var extsList = new ExtensionList(); int extsLen = BinaryHelper.Int16FromBytes(buffer[currentLen++], buffer[currentLen++]); int extOffsetEnd = currentLen + extsLen; while (currentLen < extOffsetEnd) { ExtensionType type = (ExtensionType)BinaryHelper.Int16FromBytes(buffer[currentLen++], buffer[currentLen++]); Int16 extLen = BinaryHelper.Int16FromBytes(buffer[currentLen++], buffer[currentLen++]); if (AddExtensionToResult(buffer, ref currentLen, extLen, end, knownExtensions, type, ref extsList) == false) currentLen += extLen; } return extsList; }
public ParentForm(ExtensionList videoExtensions, ExtensionList subExtensions, string[] args) { VideoExtensions = videoExtensions; SubExtensions = subExtensions; InitializeComponent(); ((ToolStripDropDownMenu)Settings2DropDownButton1.DropDown).ShowImageMargin = false; ((ToolStripDropDownMenu)HelpDropDownButton3.DropDown).ShowImageMargin = false; _tsUserControl = new ToolStripUserControl(this); //add usercontrol to drop down menu Settings2DropDownButton1.DropDownItems.Insert(0, _tsUserControl); string allFiles=""; foreach (string arg in args) allFiles = allFiles+ arg + Environment.NewLine; textBoxSubs.Text = allFiles; toolStripStatusLabel1.Text = myStringArray[0]; }
public override List<MapRelationBase> GetRelations(MappingSchema schema, ExtensionList typeExt, Type master, Type slave, out bool isSet) { var masterAccessor = TypeAccessor.GetAccessor(master); var slaveAccessor = slave != null ? TypeAccessor.GetAccessor(slave) : null; var relations = new List<MapRelationBase>(); foreach (MemberAccessor ma in masterAccessor) { var attr = ma.GetAttribute<RelationAttribute>(); if (attr == null || (slave != null && attr.Destination != slave && ma.Type != slave)) continue; if (slave == null) slaveAccessor = TypeAccessor.GetAccessor(attr.Destination ?? ma.Type); var toMany = TypeHelper.IsSameOrParent(typeof(IEnumerable), ma.Type); if (toMany && attr.Destination == null) throw new InvalidOperationException("Destination type should be set for enumerable relations: " + ma.Type.FullName + "." + ma.Name); var masterIndex = attr.MasterIndex; var slaveIndex = attr.SlaveIndex; if (slaveIndex == null) { var accessor = toMany ? masterAccessor : slaveAccessor; var tex = TypeExtension.GetTypeExtension(accessor.Type, typeExt); var keys = GetPrimaryKeyFields(schema, accessor, tex); if (keys.Count > 0) slaveIndex = new MapIndex(keys.ToArray()); } if (slaveIndex == null) throw new InvalidOperationException("Slave index is not set for relation: " + ma.Type.FullName + "." + ma.Name); if (masterIndex == null) masterIndex = slaveIndex; var relation = new MapRelationBase(attr.Destination ?? ma.Type, slaveIndex, masterIndex, ma.Name); relations.Add(relation); } isSet = true; return relations; }
/// <summary> /// takes an object and set's the version number to the /// same as this instance /// </summary> /// <param name="arr">The array of objects the version should be applied to</param> public void ImprintVersion(ExtensionList arr) { if (arr == null) return; foreach (Object o in arr) { IVersionAware v = o as IVersionAware; if (v != null) { ImprintVersion(v); } } }
protected abstract void ProcessResource( ExtensionList aExtensions );
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { var attrs = type.GetCustomAttributes(typeof(TableNameAttribute), true); if (attrs.Length > 0) { var name = ((TableNameAttribute)attrs[0]).Name; isSet = name != null; return name; } return base.GetTableName(type, extensions, out isSet); }
public AudioScanner(ADataParser parser, DirectoryInfo directory, SearchOption searchoption, params string[] extensions) { if (parser == null) throw new ArgumentNullException("parser"); if (directory == null) throw new ArgumentNullException("directory"); this.parser = parser; this.directory = directory; this.searchoption = searchoption; extensionList = new ExtensionList(extensions); existingFiles = new ExistingFilesCollection(); worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { foreach (MetadataProviderBase p in _list) { string value = p.GetTableName(type, extensions, out isSet); if (isSet) return value; } return base.GetTableName(type, extensions, out isSet); }
private ExtensionList FormExtsList(IEnumerable<ExtensionType> extensions) { if (extensions != null) { var result = new ExtensionList(); foreach (var ext in extensions) { switch (ext) { case ExtensionType.Renegotiation: result.Add(new RenegotiationExtension(this.Entity)); break; case ExtensionType.ALPN: result.Add(new ALPNExtension(this.Entity, KnownProtocols)); break; } } return result; } return null; }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { TypeExtension typeExt = TypeExtension.GetTypeExtension(type, extensions); object value = typeExt.Attributes["TableName"].Value; if (value != null) { isSet = true; return value.ToString(); } return base.GetTableName(type, extensions, out isSet); }
/////////////////////////////////////////////////////////////////////// /// <summary>Creates an ItemTypeDefinition based /// on a list of extensions.</summary> /// <param name="extensions">list of extensions to query and modify /// </param> /////////////////////////////////////////////////////////////////////// public ItemTypeDefinition(ExtensionList extensions) { this.extensions = extensions; }
public virtual void setUp() { extList = ExtensionList.NotVersionAware(); attrs = new GBaseAttributeCollection(extList); }
public virtual List<MapRelationBase> GetRelations(MappingSchema schema, ExtensionList typeExt, Type master, Type slave, out bool isSet) { isSet = false; return new List<MapRelationBase>(); }
public virtual string GetOwnerName(Type type, ExtensionList extensions, out bool isSet) { isSet = false; return null; }
public virtual void SetUp() { list = ExtensionList.NotVersionAware(); attrs = new GBaseAttributeCollectionWithTypeConversion(list); }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { foreach (var p in _list) { var value = p.GetTableName(type, extensions, out isSet); if (isSet) return value; } return base.GetTableName(type, extensions, out isSet); }
public virtual string GetTableName(Type type, ExtensionList extensions, out bool isSet) { isSet = false; return type.Name; }
private string SortFiles(List<string> fileNames, ExtensionList myExtensions) { string totalFileString = ""; foreach (string fileName in fileNames) { foreach (string myExtension in myExtensions) if (Path.GetExtension(fileName) == myExtension) { totalFileString = totalFileString + fileName + Environment.NewLine; } } if (totalFileString !="") UpdateStatusBarText(totalFileString); return totalFileString; }
/////////////////////////////////////////////////////////////////////// /// <summary>Creates a GBaseAttributes object that will access and /// modify the given extension list.</summary> /// <param name="baseList">a list that contains GBaseAttribute object, /// among others</param> /////////////////////////////////////////////////////////////////////// public GBaseAttributes(ExtensionList baseList) : base(baseList) { }
public override List<MapRelationBase> GetRelations(MappingSchema schema, ExtensionList typeExt, Type master, Type slave, out bool isSet) { foreach (var p in _list) { var relations = p.GetRelations(schema, typeExt, master, slave, out isSet); if (isSet) return relations; } return base.GetRelations(schema, typeExt, master, slave, out isSet); }
public override List<MapRelationBase> GetRelations(MappingSchema schema, ExtensionList typeExt, Type master, Type slave, out bool isSet) { var relations = new List<MapRelationBase>(); var ext = typeExt != null ? typeExt[master] : TypeExtension.Null; isSet = ext != TypeExtension.Null; if (!isSet) return relations; var ta = TypeAccessor.GetAccessor(master); foreach (var mex in ext.Members.Values) { var relationInfos = mex.Attributes[TypeExtension.NodeName.Relation]; if (relationInfos == AttributeExtensionCollection.Null) continue; var destinationTypeName = relationInfos[0][TypeExtension.AttrName.DestinationType, string.Empty].ToString(); var destinationType = slave; var ma = ta[mex.Name]; var toMany = TypeHelper.IsSameOrParent(typeof(IEnumerable), ma.Type); if (destinationTypeName == string.Empty) { if (toMany) throw new InvalidOperationException("Destination type should be set for enumerable relations: " + ma.Type.FullName + "." + ma.Name); destinationType = ma.Type; } else { if (!destinationTypeName.Contains(",")) destinationTypeName += ", " + ta.OriginalType.Assembly.FullName; try { destinationType = Type.GetType(destinationTypeName, true); } catch (TypeLoadException ex) { throw new InvalidOperationException( "Unable to load type by name: " + destinationTypeName + "\n may be assembly is not specefied, please see Type.GetType(string typeName) documentation", ex); } } if (slave != null && !TypeHelper.IsSameOrParent(slave, destinationType)) continue; var masterIndexFields = new List<string>(); var slaveIndexFields = new List<string>(); foreach (var ae in relationInfos[0].Attributes[TypeExtension.NodeName.MasterIndex]) masterIndexFields.Add(ae[TypeExtension.AttrName.Name].ToString()); foreach (var ae in relationInfos[0].Attributes[TypeExtension.NodeName.SlaveIndex]) slaveIndexFields.Add(ae[TypeExtension.AttrName.Name].ToString()); if (slaveIndexFields.Count == 0) { var accessor = toMany ? ta : TypeAccessor.GetAccessor(destinationType); var tex = TypeExtension.GetTypeExtension(accessor.Type, typeExt); slaveIndexFields = GetPrimaryKeyFields(schema, accessor, tex); } if (slaveIndexFields.Count == 0) throw new InvalidOperationException("Slave index is not set for relation: " + ma.Type.FullName + "." + ma.Name); var slaveIndex = new MapIndex(slaveIndexFields.ToArray()); var masterIndex = masterIndexFields.Count > 0 ? new MapIndex(masterIndexFields.ToArray()) : slaveIndex; var mapRelation = new MapRelationBase(destinationType, slaveIndex, masterIndex, mex.Name); relations.Add(mapRelation); } isSet = relations.Count > 0; return relations; }
public virtual string GetTableName(Type type, ExtensionList extensions, out bool isSet) { isSet = false; return type.IsInterface && type.Name.StartsWith("I") ? type.Name.Substring(1) : type.Name; }
protected override void ProcessResource( ExtensionList aExtensions ) { var document = new XElement( "ExtensionsUsed", from name in aExtensions.Names select new XElement( "Name", name ) ); SaveDocument( document, Filenames.ExtensionsUsed + ".xml" ); }
/////////////////////////////////////////////////////////////////////// /// <summary>Creates a GBaseAttributeCollectionWithTypeConversion /// object that will access and modify the given extension list. /// </summary> /// <param name="baseList">a list that contains GBaseAttribute object, /// among others</param> /////////////////////////////////////////////////////////////////////// public GBaseAttributeCollectionWithTypeConversion(ExtensionList baseList) : base(baseList) { }
/////////////////////////////////////////////////////////////////////// /// <summary>Creates an attribute collection and link it to an /// extension list.</summary> /// <param name="extensionElements">extension list to be queried and /// modified</param> /////////////////////////////////////////////////////////////////////// public GBaseAttributeCollection(ExtensionList extensionElements) : base() { this.extensionElements = extensionElements; }
public override string GetTableName(Type type, ExtensionList extensions, out bool isSet) { if (IsLinqObject(type)) { isSet = true; object[] attrs = type.GetCustomAttributes(typeof(TableAttribute), true); return ((TableAttribute)attrs[0]).Name; } return base.GetTableName(type, extensions, out isSet); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ExtensionList videoExtensions = new ExtensionList(); ExtensionList subExtensions = new ExtensionList(); #region read from xml using RND.XML //XmlStorage myXmlStorage = new XmlStorage("Extensions", System.Convert.ToChar(" ")); //try //{ // using (Stream fStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None)) // { // // // myXmlStorage.Load(fStream); // } //} //catch (Exception) //{ //} //videoExtensions = (ExtensionList)myXmlStorage.ReadEntry("VideoExt"); //subExtensions = (ExtensionList)myXmlStorage.ReadEntry("SubExt"); #endregion #region Read xml-file with user extensions using Standard XML XmlSerializer xmlFormat = new XmlSerializer(typeof(List<ExtensionList>), "Extensions"); try { using (Stream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None)) { try { List<ExtensionList> myList = (List<ExtensionList>)xmlFormat.Deserialize(fStream); videoExtensions = myList[0]; subExtensions = myList[1]; } catch (Exception) { Debug.WriteLine("xmlFormat.Deserialize(fStream) fails"); } finally { fStream.Close(); } } } catch (Exception) { Debug.WriteLine("Fail to open xml file"); } #endregion if (videoExtensions ==null ||videoExtensions.ToString() == "") { videoExtensions = ExtensionList.Parse(".avi;.mkv;.ogm;.mpeg;.mpg;.vid;.xvid;.m4v;.wmv;"); } if (subExtensions == null|| subExtensions.ToString() == "") subExtensions = ExtensionList.Parse(".srt;.ass;.ssa;.rt;.js;.sub;"); //serialize into XML Application.ApplicationExit += new EventHandler(Application_ApplicationExit); //start App myForm = new ParentForm(videoExtensions, subExtensions, args); Application.Run(myForm);//Form1(LIST) }