public static string serializeContractToString(Instantiator.ComponentFunctorApplicationType inst) { string filename = Path.GetTempFileName(); XmlSerializer serializer = new XmlSerializer(typeof(Instantiator.ComponentFunctorApplicationType)); FileStream fs = new FileStream(filename, FileMode.OpenOrCreate); XmlWriter writer = new XmlTextWriter(fs, null); serializer.Serialize(writer, inst); fs.Close(); string result = File.ReadAllText(filename); return(result); }
private string buildInstantiatorStringOfSystem(string component_ref, int facet_instance, Tuple <int, string>[] facet_address_list, int[] nodes) { IList <AbstractComponentFunctor> acf_list = BackEnd.acfdao.listByKind(Constants.KIND_APPLICATION_NAME); AbstractComponentFunctor acf = acf_list [0]; Instantiator.InstanceType instantiator = new Instantiator.InstanceType(); Instantiator.ComponentFunctorApplicationType contract = new Instantiator.ComponentFunctorApplicationType(); contract.component_ref = component_ref; contract.argument = new Instantiator.ContextArgumentType[0]; instantiator.contextual_type = contract; instantiator.facet_instanceSpecified = true; instantiator.facet_instance = facet_instance; IList <Interface> units = BackEnd.idao.list(acf.Id_abstract); instantiator.unit_mapping = new Instantiator.UnitMappingType[units.Count]; Console.WriteLine("buildInstantiatorStringOfSystem 0 " + units.Count); int iu = 0; foreach (Interface u in units) { instantiator.unit_mapping [iu] = new Instantiator.UnitMappingType(); instantiator.unit_mapping [iu].unit_id = u.Id_interface; instantiator.unit_mapping [iu].unit_index = 0; instantiator.unit_mapping [iu].facet_instanceSpecified = true; instantiator.unit_mapping [iu].facet_instance = instantiator.unit_mapping [iu].facet = u.Facet; int number_of_nodes = nodes[instantiator.unit_mapping [iu].facet_instance]; instantiator.unit_mapping [iu].node = new int[number_of_nodes]; for (int n = 0; n < number_of_nodes; n++) { instantiator.unit_mapping [iu].node [n] = n; } iu++; } Console.WriteLine("buildInstantiatorStringOfSystem 1"); instantiator.facet_address = new Instantiator.FacetAddressType[facet_address_list.Length]; for (int i = 0; i < facet_address_list.Length; i++) { instantiator.facet_address [i] = new Instantiator.FacetAddressType(); instantiator.facet_address [i].facet_instanceSpecified = true; instantiator.facet_address [i].facet_instance = instantiator.facet_address [i].facet = facet_address_list[i].Item1; instantiator.facet_address [i].facetSpecified = true; instantiator.facet_address [i].facet = instantiator.facet_address [i].facet_instance; string platform_address = facet_address_list[i].Item2 != null ? facet_address_list[i].Item2 : "http://127.0.0.1:100"; Uri uri = new Uri(platform_address); instantiator.facet_address [i].address = uri.Host; instantiator.facet_address [i].portSpecified = true; instantiator.facet_address [i].port = uri.Port; } Console.WriteLine("buildInstantiatorStringOfSystem 2"); string instantiator_string = LoaderApp.serializeInstantiator(instantiator); return(instantiator_string); }