本文整理汇总了C#中IModelSystemStructure类的典型用法代码示例。如果您正苦于以下问题:C# IModelSystemStructure类的具体用法?C# IModelSystemStructure怎么用?C# IModelSystemStructure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IModelSystemStructure类属于命名空间,在下文中一共展示了IModelSystemStructure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCorrespondingParameter
private IModuleParameter GetCorrespondingParameter(IModuleParameter p, IModelSystemStructure mss, IModelSystemStructure newMSS)
{
if ( mss == p.BelongsTo )
{
foreach ( var param in newMSS.Parameters.Parameters )
{
if ( param.Name == p.Name )
{
return param;
}
}
return null;
}
var list = mss.Children;
var newList = newMSS.Children;
if ( list == null | newList == null )
{
return null;
}
for ( int i = 0; i < list.Count; i++ )
{
var ret = GetCorrespondingParameter( p, list[i], newList[i] );
if ( ret != null )
{
return ret;
}
}
return null;
}
示例2: SetProjectRootCommand
public SetProjectRootCommand(Action<IModelSystemStructure> updateRoot, IProject project, int index, IModelSystemStructure newRoot)
{
this.UpdateRoot = updateRoot;
this.Project = project;
this.Index = index;
this.NewRoot = newRoot;
}
示例3: ModuleSwapCommand
public ModuleSwapCommand(List<ILinkedParameter> linkedParameters, IModelSystemStructure parent, int index, IModelSystemStructure newValue)
: base(linkedParameters, parent.Children[index])
{
this.Parent = parent;
this.NewValue = newValue;
this.Index = index;
}
示例4: CreateNewModelSystem
public CreateNewModelSystem(IConfiguration config, string name, string description, IModelSystemStructure strucuture, List<ILinkedParameter> linkedParameters)
{
this.Config = config;
this.Name = name;
this.Description = description;
this.Strucuture = strucuture;
this.LinkedParameters = linkedParameters;
}
示例5: ModelSystemDisplayStructure
public ModelSystemDisplayStructure(IModelSystemStructure mss)
{
this.Structure = mss;
this._Name = mss.Name;
this._Description = mss.Description;
this.Type = mss.Type;
BuildChildren();
}
示例6: MapLinkedParameters
/// <summary>
/// Map the linked parameters to finish making a clone
/// </summary>
/// <param name="originalLinkedParameters"></param>
/// <param name="newModelSystemStructure"></param>
/// <param name="oldModelSystemStructure"></param>
public static List<ILinkedParameter> MapLinkedParameters(List<ILinkedParameter> originalLinkedParameters,
IModelSystemStructure newModelSystemStructure, IModelSystemStructure oldModelSystemStructure)
{
var ret = new List<ILinkedParameter>( originalLinkedParameters.Count );
//first make a cloned copy of the original parameters
for ( int i = 0; i < originalLinkedParameters.Count; i++ )
{
ret.Add( CopyLinkedParameter( originalLinkedParameters[i] ) );
}
// now that we have a copy we need to walk the model system and live translate it.
WalkAndMoveParameters( ret, newModelSystemStructure, oldModelSystemStructure );
return ret;
}
示例7: GetParameters
private static Parameter[] GetParameters(IModelSystemStructure mss)
{
var list = mss.Parameters;
if ( list == null )
{
return null;
}
var length = list.Parameters.Count;
Parameter[] ret = new Parameter[length];
for ( int i = 0; i < length; i++ )
{
ret[i] = new Parameter()
{
Type = list.Parameters[i].Type == null ? "No Type" : ConvertTypeName( list.Parameters[i].Type ),
Name = list.Parameters[i].Name,
Description = list.Parameters[i].Description
};
}
return ret;
}
示例8: RunTimeValidation
/// <summary>
/// Validate the model system before starting to execute it
/// </summary>
/// <param name="error">If there is an error, the error message will be stored in here</param>
/// <param name="currentPoint">The current point through the tree we are testing</param>
/// <returns></returns>
private bool RunTimeValidation(ref string error, IModelSystemStructure currentPoint)
{
try
{
// if there is a module at this point
if ( currentPoint.Module != null )
{
if ( !currentPoint.Module.RuntimeValidation( ref error ) )
{
return false;
}
}
// check to see if there are descendants that need to be checked
if ( currentPoint.Children != null )
{
foreach ( var module in currentPoint.Children )
{
if ( !this.RunTimeValidation( ref error, module ) )
{
Console.WriteLine( "Validation error in module " + module.Name + "\r\n" + error );
return false;
}
}
}
// if all of our children are alright, and we are also alright this part of the tree is ready to run
return true;
}
catch
{
return false;
}
}
示例9: CleanUp
private void CleanUp(IModelSystemStructure mss)
{
if ( mss.Module != null )
{
var disp = mss.Module as IDisposable;
if ( disp != null )
{
disp.Dispose();
}
mss.Module = null;
}
if ( mss.Children != null )
{
foreach ( var child in mss.Children )
{
CleanUp( child );
}
}
}
示例10: LoadChildFromXTMF
private bool LoadChildFromXTMF(ref string error)
{
IModelSystemStructure ourStructure = null;
if(ModelSystemReflection.FindModuleStructure(Config, this, ref ourStructure))
{
foreach(var child in ourStructure.Children)
{
if(child.ParentFieldName == "Child")
{
ChildStructure = child;
break;
}
}
}
if(ChildStructure == null)
{
error = "In '" + Name + "' we were unable to find the Client Model System!";
return false;
}
return true;
}
示例11: FindModuleStructure
/// <summary>
/// Retrieve the model system structure from the given project
/// </summary>
/// <param name="project">The project to analyze</param>
/// <param name="toFind">The module to find the structure of</param>
/// <param name="modelSystemStructure">The model system structure of the module to find.</param>
/// <returns>True if the module was found, false otherwise</returns>
public static bool FindModuleStructure(IProject project, IModule toFind, ref IModelSystemStructure modelSystemStructure)
{
foreach(var ms in project.ModelSystemStructure)
{
if(FindModuleStructure(ms, toFind, ref modelSystemStructure))
{
return true;
}
}
return false;
}
示例12: WalkAndMoveParameters
private static void WalkAndMoveParameters(List<ILinkedParameter> ret, IModelSystemStructure newModelSystemStructure, IModelSystemStructure oldModelSystemStructure)
{
// we only need to walk if we are not a collection since collections can not have parameters
if ( !oldModelSystemStructure.IsCollection )
{
// for each linked parameter
for ( int i = 0; i < ret.Count; i++ )
{
//check the links to see if they are attached to the old system
var parameters = ret[i].Parameters;
for ( int k = 0; k < parameters.Count; k++ )
{
if ( parameters[k].BelongsTo == oldModelSystemStructure )
{
var variableName = parameters[k].VariableName;
var newModuleParameters = newModelSystemStructure.Parameters.Parameters;
for ( int j = 0; j < newModuleParameters.Count; j++ )
{
if ( variableName == newModuleParameters[j].VariableName )
{
parameters[k] = newModuleParameters[j];
break;
}
}
}
}
}
}
var oldChildren = oldModelSystemStructure.Children;
if ( oldChildren == null ) return;
var newChildren = newModelSystemStructure.Children;
// Now that we have finished mapping all of the variables inside of this we need to walk the children
for ( int i = 0; i < oldModelSystemStructure.Children.Count; i++ )
{
WalkAndMoveParameters( ret, newChildren[i], oldChildren[i] );
}
}
示例13: EditModelSystemTemplate
private void EditModelSystemTemplate(IModelSystemStructure msscopy, int i)
{
IModuleParameters parameterList;
// First edit our children
foreach ( var child in msscopy.Children )
{
if ( child.ParentFieldType.Name == "INetworkEstimationAI" )
{
parameterList = child.Parameters;
foreach ( var param in parameterList.Parameters )
{
if ( param.Name == "Random Seed" )
{
param.Value = this.RandomNumberGenerator.Next();
}
}
}
else if ( child.ParentFieldType.Name == "INetworkAssignment" )
{
parameterList = child.Parameters;
foreach ( var param in parameterList.Parameters )
{
if ( param.Name == "Emme Project Folder" )
{
param.Value = String.Format( "{0}-{1}/Database", this.NetworkBaseDirectory, ( i + 1 ) );
}
}
}
}
// after they are setup we just need to tune a couple of our parameters
parameterList = msscopy.Parameters;
foreach ( var param in parameterList.Parameters )
{
if ( param.Name == "Emme Input Output" )
{
param.Value = String.Format( "{0}-{1}/Database/cache/scalars.311", this.NetworkBaseDirectory, ( i + 1 ) );
}
else if ( param.Name == "Emme Macro Output" )
{
param.Value = String.Format( "{0}-{1}/Database/cache/boardings_predicted.621", this.NetworkBaseDirectory, ( i + 1 ) );
}
}
}
示例14: IndexOf
internal int IndexOf(ModelSystemDisplayStructure[] oldChildren, IModelSystemStructure modelSystemStructure)
{
for ( int i = 0; i < oldChildren.Length; i++ )
{
if ( oldChildren[i].Structure == modelSystemStructure )
{
return i;
}
}
return -1;
}
示例15: BuildModelStructureChain
/// <summary>
/// Gets the ancestry of a module from the given root.
/// </summary>
/// <param name="root">The first node to look at.</param>
/// <param name="toFind">The module to find</param>
/// <param name="chain">The chain to store the results into.</param>
/// <returns>True if we found the module, false otherwise</returns>
public static bool BuildModelStructureChain(IModelSystemStructure root, IModule toFind, List<IModelSystemStructure> chain)
{
if(root.Module == toFind)
{
chain.Add(root);
return true;
}
if(root.Children != null)
{
foreach(var child in root.Children)
{
if(BuildModelStructureChain(child, toFind, chain))
{
chain.Insert(0, root);
return true;
}
}
}
// Then we didn't find it in this tree
return false;
}