private McgField[] ComputeAllFields(Stack containingTypes) { ArrayList fields = new ArrayList(); if (Extends != null) { if (containingTypes.Contains(Extends)) { ArrayList al = new ArrayList(); foreach (McgType type in containingTypes.ToArray()) { al.Add(type.Name); } throw new ApplicationException(String.Format( "Recursive type definition. Tried to push {0} onto stack: {1}", Extends.Name, String.Join("; ", (string[])al.ToArray(typeof(string))))); } containingTypes.Push(this); fields.AddRange(Extends.ComputeAllFields(containingTypes)); containingTypes.Pop(); } fields.AddRange(LocalFields); return((McgField[])fields.ToArray(typeof(McgField))); }
private async void Clustering_Click(object sender, RoutedEventArgs e) { StatusProgress.Visibility = Visibility.Visible; Extends.Post(() => StatusText.Text = $"VP-Tree를 생성하는 중..."); double rate; if (!double.TryParse(MaxRate.Text, out rate)) { MessageBox.Show("클러스터링 최고 역치는 실수여야합니다!", "Gallery Explorer", MessageBoxButton.OK, MessageBoxImage.Error); return; } await Task.Run(() => { var clustered = iss.Clustering(x => { Extends.Post(() => StatusText.Text = $"클러스터링 중 ... [{x.Item1.ToString("#,#")}/{x.Item2.ToString("#,#")}] ({(x.Item1 / (double)x.Item2 * 100.0).ToString("#0.00")} %)"); }, 50, rate); Extends.Post(() => { var vm = ResultList.DataContext as ImageSimilarityDataGridViewModel; vm.Items.Clear(); clustered.Where(x => x.Count >= 2).ToList().ForEach(x => vm.Items.Add(new ImageSimilarityDataGridItemViewModel { 개수 = x.Count.ToString(), 평균_정확도 = x.Max(y => y.Item2).ToString(), results = x })); }); }); StatusProgress.Visibility = Visibility.Collapsed; Extends.Post(() => StatusText.Text = $"클러스터링이 완료되었습니다."); }
/// <summary>获取扩展属性,获取数据时向指定的依赖实体类注册数据更改事件</summary> /// <typeparam name="TDependEntity">依赖实体类,该实体类数据更改时清空所有依赖于实体类的扩展属性</typeparam> /// <typeparam name="TResult">返回类型</typeparam> /// <param name="key">键值</param> /// <param name="func">回调</param> /// <param name="cacheDefault">是否缓存默认值,可选参数,默认缓存</param> /// <returns></returns> protected virtual TResult GetExtend <TDependEntity, TResult>(String key, Func <String, Object> func, Boolean cacheDefault) where TDependEntity : Entity <TDependEntity>, new() { Object value = null; if (Extends.TryGetValue(key, out value)) { return((TResult)value); } if (StopExtend) { return(default(TResult)); } // 针对每个类型,仅注册一个事件 Type type = typeof(TDependEntity); List <String> list = null; if (!Depends.TryGetValue(type, out list)) { list = new List <String>(); Depends.Add(type, list); } // 这里使用了成员方法GetExtend<TDependEntity>而不是匿名函数,为了避免生成包装类,且每次调用前实例化包装类带来较大开销 return((TResult)Extends.GetItem <Func <String, Object>, List <String> >(key, func, list, new Func <String, Func <String, Object>, List <String>, Object>(GetExtend <TDependEntity>), cacheDefault)); }
private void process_folder(string path) { var files = Directory.GetFiles(path).Where(x => x.EndsWith(".png") || x.EndsWith(".jpg") || x.EndsWith(".jpeg") || x.EndsWith(".bmp") || x.EndsWith(".webp")); var total = files.Count(); var count = 0; Parallel.ForEach(files, x => { iss.AppendImage(x); Extends.Post(() => { var cc = Interlocked.Increment(ref count); StatusText.Text = $"이미지 파일 분석 중 ... [{cc.ToString("#,#")}/{total.ToString("#,#")}] ({(cc / (double)total * 100.0).ToString("#0.00")} %) {x}"; }); }); var result = new List <(string, ulong[])>(); foreach (var kv in iss.Hashs) { result.Add((kv.Key, kv.Value)); } var fn = $"iss-{System.IO.Path.GetFileName(path)}-{DateTime.Now.Ticks}.iss"; File.WriteAllText(fn, JsonConvert.SerializeObject(result)); Extends.Post(() => StatusText.Text = $"'{fn}' 파일로 분석 결과가 자동저장 되었습니다."); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (loaded) { return; } loaded = true; Task.Run(() => { bool err = false; TalkInstance.Instance.Open(filename); Extends.Post(() => { Message.Text = TalkInstance.Instance.Title; Message2.Text = "대화를 분석 중입니다..."; Message2.Visibility = Visibility.Visible; }); try { TalkInstance.Instance.Parse(); TalkInstance.Instance.Manager.ExtractMember(); } catch (Exception ex) { Monitor.Instance.Save(); err = true; } Extends.Post(() => MainWindow.Instance.CloseDialog(!err)); }); }
public string getGenerarCod(string datos) { try { LogRepository.registro("ENTRA AL METODO getGenerarCod "); char[] MyChar = { ' ' }; var usuarioLog = ((Usuarios)Session["USUARIO_LOGUEADO"]).IdUsuario; var dato = datos.Split(';'); var oficina = (dato[0].TrimStart(MyChar)).TrimEnd(MyChar); var sociedad = (dato[1].TrimStart(MyChar)).TrimEnd(MyChar); var codigo = (dato[2].TrimStart(MyChar)).TrimEnd(MyChar); var fecha = dato[3]; var idRadicacion = dato[4]; var nombreImpresora = db.Usuarios.Where(x => x.IdUsuario == usuarioLog).First().Periferico_Impresora; var respuesta = new Extends().CrearEImprimirEtiqueta(oficina, fecha, sociedad, codigo, nombreImpresora, usuarioLog, idRadicacion); string mensaje = string.Empty; if (respuesta == true) { mensaje = "1"; } else { mensaje = "0"; } return(mensaje); } catch (Exception es) { LogRepository.registro("Error en RadicacionController metodo getGenerarCod " + es.Message); return("Error al imprimir el codigo"); throw; } }
public override string ToString() { string ret = ""; foreach (Qualifier qualifier in Qualifiers) { ret += Enum.GetName(typeof(Qualifier), qualifier).ToLower() + " "; } ret += "class " + Name.ToString(); if (Extends != null) { ret += " extends " + Extends.ToString(); } if (Implements.Count > 0) { ret += " implements "; foreach (TypeReference type in Implements) { ret += type.ToString() + ", "; } ret = ret.Substring(0, ret.Length - 2); } return(ret); }
private async void KeywordButton2_Click(object sender, RoutedEventArgs e) { keyword_control(false); Progress.Maximum = TalkInstance.Instance.Manager.Talks.Count; var op1 = WAOption1.IsChecked.Value; var op3 = WAOption3.IsChecked.Value; var op4 = WAOption4.IsChecked.Value; var op5 = WAOption5.IsChecked.Value; await Task.Run(() => { TalkInstance.Instance.Manager.StartAllMessageAnalyzeByDate(x => { Extends.Post(() => { Progress.Value = x; ProgressLabel.Text = $"[{Progress.Value.ToString("#,0")}/{Progress.Maximum.ToString("#,0")}]"; }); }, op1, op5, op3, op4); }); (new MonthlyKeywords()).Show(); keyword_control(true); }
private void BuildLanguage(Dictionary <string, LanguageTable> tables, bool build) { string allLanguages = ConversionUtil.GetConfig(ConfigKey.AllLanguage, ConfigFile.LanguageConfig); //string languageDirectory = ConversionUtil.GetPath(ConversionUtil.GetConfig(ConfigKey.LanguageDirectory, ConfigFile.LanguageConfig)); string languageDirectory = ConversionUtil.GetPath(textTableFolder.Text); LanguageBuilder builder = new LanguageBuilder( allLanguages, languageDirectory, ConversionUtil.GetPath(ConversionUtil.GetConfig(ConfigKey.TranslationDirectory, ConfigFile.LanguageConfig)), tables); bool success = build ? builder.Build() : builder.RefreshLanguage(); if (success) { string[] languages = builder.GetLanguages(); List <string> languageFiles = new List <string>(); foreach (var language in languages) { languageFiles.Add(languageDirectory + "/Language_" + language + ".xls"); } new TableBuilder().Transform(string.Join(";", languageFiles.ToArray()), textTableConfig.Text, textBoxPackage.Text, ConversionUtil.GetConfig(ConfigKey.SpawnList, ConfigFile.InitConfig), false, Extends.GetChecked(refreshNote), ConversionUtil.GetProgramConfig()); } }
public ToolsList() { this.InitializeComponent(); Dispatcher.RunIdleAsync((_) => { Extends.Add(Clipper); Extends.Add(new Model.Tools.ResizeModel()); Extends.Add(new Model.Tools.PickerModel()); Extends.Add(new Model.Tools.BuckerModel()); Extends.Add(new Model.Tools.TxEditModel()); Extends.Add(new Model.Tools.FillModel()); //Extends.Add(new ToolsModel() { // Icon = "ms-appx:///Assets/AppBar/bucker.png", // Name = "bucker", //}); //Extends.Add(new ToolsModel() { // Icon = "ms-appx:///Assets/AppBar/text.png", // Name = "text", //}); VModel.vm.RegisterPropertyChangedCallback(VModel.CurrentToolsProperty, (s, e) => { SetSelected((ToolsModel)s.GetValue(e)); }); }).ToString(); }
public void Make(Type type) { Attributes.Add <Generated>(); Extends.Add(typeof(ISerializer <>).MakeGenericType(type)); var read = AddMethod("Read").Public.Void; read.Argument.Add <BinaryReader>().Add("reader"); read.Argument.Out.Add(type).Add("value"); var write = AddMethod("Write").Public.Void; write.Argument.Add <BinaryWriter>().Add("writer"); write.Argument.In.Add(type).Add("value"); int index = 0; Dictionary <Type, string> serializerFieldByType = new Dictionary <Type, string>(); foreach (var field in FindSerializableFields(type)) { Type fieldType = field.FieldType; string fieldName = field.Name; if (fieldType.IsEnum) { read.Line.Add($"value.{fieldName} = (") .Add(fieldType) .Add(")reader.ReadInt32();"); write.Add($"writer.Write((int)value.{field.Name});"); } else if (ReadMethodByType.TryGetValue(fieldType, out string readerMethodName)) { read.Add($"value.{fieldName} = reader.{readerMethodName}();"); write.Add($"writer.Write(value.{field.Name});"); } else if (!fieldType.IsValueType) { // TODO WARNING AHTUNG read.Line.Add($"value.{fieldName} = (") .Add(fieldType) .Add(")new ") .Add <BinaryFormatter>() .Add("().Deserialize(reader.BaseStream);"); write.Line.Add("new ") .Add <BinaryFormatter>() .Add($"().Serialize(writer.BaseStream, value.{fieldName});"); } else { if (!serializerFieldByType.TryGetValue(fieldType, out string serFieldName)) { serFieldName = $"_ser{index++}{SimpleName(fieldType)}"; serializerFieldByType.Add(fieldType, serFieldName); Fields.Line.Add("private static ").Add(typeof(ISerializer <>), fieldType).Add($" {serFieldName} = null;"); _requiredSerializerSet.Add(fieldType); } read.Line.Add($"{serFieldName}.Read(reader, out value.{fieldName});"); write.Line.Add($"{serFieldName}.Write(writer, in value.{fieldName});"); } } }
internal override SObject ExecuteMethod(ScriptProcessor processor, string methodName, SObject caller, SObject This, SObject[] parameters) { InitializeStatic(); AddObjectPrototypeAsExtends(processor); bool isStaticCall = ReferenceEquals(caller, this); // Call any static function defined in this prototype: if (_prototypeMembers.ContainsKey(methodName) && _prototypeMembers[methodName].IsStatic) { if (_prototypeMembers[methodName].IsFunction) { var cFunction = (SFunction)_prototypeMembers[methodName].Data; return(cFunction.Call(processor, caller, this, parameters)); // For a static method, the "This" attribute is the prototype. } else { return(processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_TYPE_NOT_A_FUNCTION, methodName)); } } // Call the super class prototype, if one exists: if (Extends != null) { return(Extends.ExecuteMethod(processor, methodName, caller, This, parameters)); } return(processor.ErrorHandler.ThrowError(ErrorType.ReferenceError, ErrorHandler.MESSAGE_REFERENCE_NOT_DEFINED, methodName)); }
public override void AddObjectVariablesToAssigner(IWorkshopTree reference, VarIndexAssigner assigner) { Extends?.AddObjectVariablesToAssigner(reference, assigner); for (int i = 0; i < ObjectVariables.Count; i++) { ObjectVariables[i].AddToAssigner((Element)reference, assigner); } }
private static void CheckedChanged(object sender, EventArgs e) { if (m_AutoConfigs.ContainsKey(sender)) { AutoConfig config = m_AutoConfigs[sender]; SetConfig(config.program, config.key, Extends.GetChecked((CheckBox)sender) ? "true" : "false", config.file); } }
public override void ReadExtendProperty(BinaryReader reader, DataFieldItem dataItem) { PropertyInfo property = dataItem.Property; DataFieldAttribute att = dataItem.Attribute; if (property.Name == "ExternalComponentTable") { long offset = 0; if (property.PropertyType == typeof(Int32)) { offset = (Int32)property.GetValue(this, null); } else { offset = (Int16)property.GetValue(this, null); } if (offset <= 0) { return; } Int32 count = Convert.ToInt32(this["ExternalComponentCount"]); if (count <= 0) { return; } long address = GetRealAddress(offset, dataItem.Attribute.RefKind); // 超出文件结尾时,终止读取 if (address <= 0 || address > reader.BaseStream.Length) { Extends.Add(property.Name, null); return; } // Info.Objects只存单个对象,不存集合,所以这里不用判断 List <ExternalComponentTable> list = new List <ExternalComponentTable>(); for (int i = 0; i < count; i++) { ExternalComponentTable entity = new ExternalComponentTable(); // 读取对象 Seek(reader, address); entity.Info = Info; entity.Read(reader); list.Add(entity); address += entity.StructLength; } Extends.Add(property.Name, list.ToArray()); return; } base.ReadExtendProperty(reader, dataItem); }
/// <summary> /// /// </summary> /// <param name="file"></param> /// <param name="id"></param> public TrainData(string file, int id) { MatrixData = Extends.GetDim1Matrix(file); Anwser = new double[MatrixData.GetLength(0), 7]; for (int i = 0; i < Anwser.GetLength(0); i++) { Anwser[i, id] = 1; } }
private static void RichTextChanged(object sender, EventArgs e) { if (m_AutoConfigs.ContainsKey(sender)) { RichTextBox textBox = (RichTextBox)sender; AutoConfig config = m_AutoConfigs[sender]; SetConfig(config.program, config.key, Extends.GetText(textBox).Replace("\n", ";"), config.file); } }
/// <summary> /// This build process should be run atomically. /// </summary> /// <param name="output_filename"></param> public void Build() { NetTaskPass.RemoveFromPasses <FreeProxyPass>(); var proxies = new List <ProxyInfo>(); proxies.AddRange(BuildFromFreeProxyListsNet()); Extends.WriteJson(Path.Combine(AppProvider.ApplicationPath, "freeproxy.txt"), proxies); }
public override int GetHashCode() { unchecked { var hashCode = Implements.GetSetHashCode(); hashCode = (hashCode * 397) ^ (Extends != null ? Extends.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Element.GetHashCode()); return(hashCode); } }
public override void BaseSetup(ActionSet actionSet, Element reference) { if (Extends != null) { Extends.BaseSetup(actionSet, reference); } foreach (ObjectVariable variable in ObjectVariables) { variable.Init(actionSet, reference); } }
private void buttonTransform_Click(object sender, EventArgs e) { StartRun(() => { new TableBuilder().Transform(this.textTransformFiles.Text, ConversionUtil.GetPath(textTableConfig.Text), textBoxPackage.Text, ConversionUtil.GetConfig(ConfigKey.SpawnList, ConfigFile.InitConfig), Extends.GetChecked(getManager), Extends.GetChecked(refreshNote), ConversionUtil.GetProgramConfig()); }); }
/// <summary> /// Guarda el archivo en una ruta especifica para porder leerlo /// </summary> public ActionResult SaveFile(IEnumerable <HttpPostedFileBase> attachments) { try { // The Name of the Upload component is "attachments" foreach (var file in attachments) { // Some browsers send file names with full path. This needs to be stripped. var fileName = Path.GetFileName(file.FileName); if (Extends.ValidarExtencion(fileName)) { // var reNameFile = RenombrarArchivo(fileName); var physicalPath = Path.Combine(Server.MapPath("/App_Data/ArchivosVirtuales/"), fileName); // The files are not actually saved in this demo file.SaveAs(physicalPath); if (Path.GetExtension(fileName) == ".tif") { Extends s = new Extends(); var rutaFisicaTIF = Path.Combine(Server.MapPath("/App_Data/ArchivosVirtuales/"), fileName); string[] archivo = fileName.Split('.'); string nomArchivo = archivo[0].ToString() + ".pdf"; var rutaFisicaPDF = Path.Combine(Server.MapPath("/App_Data/ArchivosVirtuales/"), nomArchivo); s.ConvertirImagenTifaPDF(rutaFisicaTIF, rutaFisicaPDF); physicalPath = rutaFisicaPDF; fileName = nomArchivo; } Session["CURRENT_FILE"] = physicalPath; string rutaOrigen = db.Parametros.Where(c => c.codigo == "PATH_ARCH_VIRTUAL").First().valor; string pdf = @"" + rutaOrigen + fileName; string tiff = @"" + rutaOrigen + RenombrarArchivoExttiff(fileName); Session["NumPages"] = Extends.ConvertirimagenPDFaTIFF(pdf, tiff); } else { throw new System.InvalidOperationException("Ingrese un archivo con extencion correcta"); } } // Return an empty string to signify success } catch (Exception e) { LogRepository.registro("Error en RadicacionController metodo SaveFile " + e.Message + " stack trace " + e.StackTrace); throw; } return(Content("")); }
/// <summary> /// Creates an instance derived from this prototype. /// </summary> internal SProtoObject CreateInstance(ScriptProcessor processor, SObject[] parameters, bool executeCtor) { SProtoObject obj = CreateBaseObject(); obj.IsProtoInstance = true; obj.AddMember(MEMBER_NAME_PROTOTYPE, this); if (typeof(ObjectPrototype) != GetType()) { // If no extends class is explicitly specified, "Object" is assumed. if (Extends == null) { Extends = processor.Context.GetPrototype("Object"); } var superInstance = Extends.CreateInstance(processor, null, true); obj.AddMember(MEMBER_NAME_SUPER, superInstance); } foreach (var member in GetInstanceMembers()) { obj.AddMember(member.Identifier, member.Data); } var indexerGetFunction = GetIndexerGetFunction(); if (indexerGetFunction != null) { obj.IndexerGetFunction = indexerGetFunction; } var indexerSetFunction = GetIndexerSetFunction(); if (indexerSetFunction != null) { obj.IndexerSetFunction = indexerSetFunction; } if (executeCtor) { Constructor?.ToFunction().Call(processor, obj, obj, parameters); } // Lock all readonly members after the constructor call, so they can be set in the constructor: foreach (PrototypeMember member in GetReadOnlyInstanceMembers()) { obj.Members[member.Identifier].IsReadOnly = true; } return(obj); }
/// <summary> /// Возвращает сигналы на входе следующего слоя. /// </summary> /// <param name="inputs"></param> /// <param name="outputs">Сигнал на выходе слоя.</param> /// <returns></returns> public override double[] GetOutputVector(double[] inputs, out double[] outputs) { double[] neuronsOutput = CalculateOutput(inputs); double[] preparedSignal = new double[nextLayerSize]; Extends.For(nextLayerSize, neuronsOutput.Length, (i, j) => { preparedSignal[i] += neuronsOutput[j] * neurons[j].Weights[i]; }); outputs = neuronsOutput; return(preparedSignal); }
protected override void WriteObjectConstraint(ICSharpFormatter formatter) { string baseClasses = null; if (!DisableBaseClassImplementation) { baseClasses = string.Join(", ", Extends.Concat(Implements).ToList().ConvertAll(cls => cls.Name)); if (!string.IsNullOrEmpty(baseClasses)) { baseClasses = " : " + baseClasses; } formatter.Write(baseClasses); } base.WriteObjectConstraint(formatter); }
//public override void Show() //{ // base.Show(); // DesignerInfo entity = this.DesignerData2; // entity.ReadExtend(); // WriteLine(String.Empty); // entity.Show(); //} public override void ReadExtendProperty(BinaryReader reader, DataFieldItem dataItem) { if (dataItem.Property.Name == "ObjectName") { // ObjectName的偏移量也是相对于ComRegData的Address,而不是相对于自己的Address long address = RegData.Address + ObjectName; Seek(reader, address); //entity.Extends["ObjectName"] = ReadString(reader); Extends.Add("ObjectName", ReadString(reader)); return; } base.ReadExtendProperty(reader, dataItem); }
public static void Bind(CheckBox textBox, PROGRAM program, string key, ConfigFile file) { if (m_AutoConfigs.ContainsKey(textBox)) { return; } AutoConfig config = new AutoConfig() { program = program, key = key, file = file }; Extends.SetChecked(textBox, Util.ToBoolean(GetConfig(program, key, file), false)); Extends.RegisterEvent(textBox, new System.EventHandler(CheckedChanged)); m_AutoConfigs[textBox] = config; }
public static void Bind(TextBox textBox, PROGRAM program, string key, ConfigFile file) { if (m_AutoConfigs.ContainsKey(textBox)) { return; } AutoConfig config = new AutoConfig() { program = program, key = key, file = file }; textBox.Text = GetConfig(program, key, file); Extends.RegisterEvent(textBox, new System.EventHandler(TextChanged)); m_AutoConfigs[textBox] = config; }
public override void Delete(ActionSet actionSet, Element reference) { if (Extends != null && Extends.CanBeDeleted) { Extends.Delete(actionSet, reference); } foreach (ObjectVariable objectVariable in ObjectVariables) { actionSet.AddAction(objectVariable.ArrayStore.SetVariable( value: new V_Number(0), index: reference )); } }
void ReadOptionalHeader() { if (hasRead) { return; } hasRead = true; Seek(Reader, NewExeHeader + FileHeader.ObjectSize); OptionalHeader entity = new OptionalHeader(); entity.Info = Info; entity.Read(Reader); Extends.Add("OptionalHeader", entity); }
void WriteExtends(Extends e) { writer.WriteStartElement(extends, namespaceURI); writer.WriteAttributeString(rule, e.RuleID); writer.WriteEndElement(); }
Extends ReadExtends(XmlElement e) { Extends extends = new Extends(); extends.RuleID = e.GetAttribute("rule"); return extends; }