本文整理汇总了C#中KacTalk.ktList类的典型用法代码示例。如果您正苦于以下问题:C# ktList类的具体用法?C# ktList怎么用?C# ktList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ktList类属于KacTalk命名空间,在下文中一共展示了ktList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ktXML
public ktXML(ktList List)
: this()
{
if (List == null)
{
return;
}
if (List.Node != null)
{
m_Node = new ktXMLNode(List.Node);
}
else
{
m_Node = new ktXMLNode("post");
}
//ktDebug.Log( "POST:" + List.Get_R( "\t", true ) + "=###=#==#=#==##==#=#=#=");
List.Reset();
foreach (ktList L in List)
{
if (L != null)
{
AddList(new ktXML(L));
}
}
}
示例2: Add
/// <summary>
/// Add values to the integer (changes the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to add to the integer</param>
/// <returns>The sum of all the arguments and the internal integer</returns>
public ktValue Add(ktList Arguments)
{
ktValue Value = ktValue.Null;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't add nothing (null) to an integer!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Try to convert the argument to an int and add it to the internal integer
m_value += GetAsInt((ktValue)L.Node.Value);
}
// Wrap this object in a ktValue ...
Value = new ktValue("return", "ktInt", this, m_HardType, true);
// ... and return it
return Value;
}
示例3: Run
public ktValue Run(ktList Arguments)
{
if (m_function == null)
{
throw new ktError("No function defined in ktFunction wrapper class!", ktERR.NOTDEF);
}
return m_function.Run(Arguments);
}
示例4: Compare
public override int Compare(ktString op, ktList arguments)
{
if (arguments.Count == 1)
{
return Compare(op, (ktValue)arguments.FirstNode.Value);
}
else
{
throw new ktError("Compare for more than 1 value is not implemented in '" + this.m_Name + "'!");
}
}
示例5: ktClass
public ktClass(ktString Name, ktClass Parent, ktList Properties, ktList Methods,
bool AddIfNotSet, bool IsClass_, bool HardType = false, bool IsConstant = false)
: base("ktClass", 0)
{
m_Name = Name;
m_Parent = Parent;
m_Properties = Properties;
m_Methods = Methods;
m_AddIfNotSet = AddIfNotSet;
m_IsClass = IsClass_;
m_HardType = HardType;
m_IsConstant = IsConstant;
}
示例6: ktBlock
}/*
public ktBlock( ktBlock Block ) : this()
{
SetBlock( Block );
}*/
public bool SetLines(ktList Lines)
{
if (Lines == null)
{
return false;
}
/* * /
m_Lines = new ktList( Lines );/*/
m_Lines = Lines;/* */
return true;
}
示例7: AddContext
public bool AddContext(ktContext Context)
{
if (Context == null)
{
return false;
}
if (m_Contexts == null)
{
m_Contexts = new ktList();
}
return m_Contexts.Add(Context.Name, Context);
}
示例8: Assign
/// <summary>
/// Assign a value to the float
/// </summary>
/// <param name="Arguments">The value to assign</param>
/// <returns>ktValue with the current object</returns>
public ktValue Assign(ktList Arguments)
{
ktValue Value = ktValue.Null;
// Can't assign nothing..
if ((Arguments.IsEmpty()) || ((ktValue)Arguments.First.Node.Value).IsNull())
{
throw new ktError("Can't assign nothing (null) to a float!", ktERR.NOTDEF);
}
// Store the first value given as argument (ignore the rest)
m_value = GetAsFloat((ktValue)Arguments.First.Node.Value);
// Return this object wrapped in a ktValue
return new ktValue(this.Name, "ktFloat", this, m_HardType, false);
}
示例9: ktDelegateFunction
public ktDelegateFunction(ktString Name, ktFunction_Double_Delegate Delegate)
: base(Name, null, null, ktValue.Null)
{
m_Arguments = new ktList();
m_Arguments.Add(new ktValue("D", "double",
kacTalk.Main.GetClass("double"),
true, true));
m_Delegate = delegate(ktList Args)
{
if ((Args == null) || (Args.FirstNode == null) ||
(Args.FirstNode.Value == null))
{
throw new ktError("Didn't get an argument for '" +
Name + "'!", ktERR.MISSING);
}
//ktDebug.Log( "ktDF::DOUBLE(" +Args.FirstNode.Value.ToString() + ")" );
ktString S_In = new ktString(Args.FirstNode.Value.ToString());
double D_In = 0.0;
double D_Out = 0.0;
try
{
if (System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator == ",")
{
S_In.Replace(".", ",", true);
}
D_In = S_In.ToDouble();
}
catch (Exception E)
{
if (E.GetType() == typeof(System.FormatException) && !S_In.IsEmpty())
{
throw new ktError("ktDouble::CreateObject: Cant make '" + S_In + "' into an double", ktERR.WRONGTYPE);
}
}
ktDebug.Log("D_In: " + D_In.ToString());
D_Out = Delegate(D_In);
ktDebug.Log("D_Out: " + D_Out.ToString());
return new ktValue("return", "double",
kacTalk.Main.MakeObjectOf("double", D_Out),
true, true);
};
}
示例10: Output
public static ktValue Output( ktList Arguments )
{
string str, ret = "";
foreach (ktList L in Arguments)
{
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
str = L.Node.ValueToString();
ret += str;
Console.WriteLine("OUTPUT:" + str );
try
{
Form1.LogText( str );
} catch (Exception) {}
}
return new ktValue("return", "ktString", new ktStringClass(ret), true, true);
}
示例11: _RunMethod
public override ktValue _RunMethod(ktString Name, ktList Arguments)
{
ktValue Value = ktValue.Null;
switch (Name.AsLower())
{
case "run":
case "_run":
case "execute":
case "_execute":
case "_func_call":
{
Value = Run( Arguments );
break;
}
default:
{
throw new ktError("Couldn't find the method '" +
Name + "' in class '" + m_Name + "'.", ktERR._404);
}
}
return Value;
}
示例12: ktRunStatement
public ktRunStatement(ktList Statement, ktBlock Block)
: base("ktRunStatement", 0)
{
m_Statement = Statement;
m_Block = Block;
}
示例13: _RunMethod
/// <summary>
/// Run a method
/// </summary>
/// <param name="Name"></param>
/// <param name="Arguments"></param>
/// <returns></returns>
public override ktValue _RunMethod(ktString Name, ktList Arguments)
{
ktValue Value = ktValue.Null;
//ktDebug.Log("ktInt::" + Name);
// Check the name of the method to call and call appropriate method
switch (Name.AsLower())
{
case "_add":
case "op+":
case "operator+":
{
Value = _Add(Arguments);
break;
}
case "add":
case "op+=":
case "operator+=":
case "_append":
{
CheckIfConstant(Name);
Value = Add(Arguments);
break;
}
case "increase":
case "op++":
case "operator++":
case "_increase":
{
CheckIfConstant(Name);
Value = Increase();
break;
}
case "_subtract":
case "op-":
case "operator-":
{
Value = _Subtract(Arguments);
break;
}
case "op-=":
case "operator-=":
case "subtract":
{
CheckIfConstant(Name);
Value = Subtract(Arguments);
break;
}
case "decrease":
case "op--":
case "operator--":
case "_decrease":
{
CheckIfConstant(Name);
Value = Decrease();
break;
}
case "_multiply":
case "_times":
case "op*":
case "operator*":
{
Value = _Multiply(Arguments);
break;
}
case "multiply":
case "times":
case "op*=":
case "operator*=":
{
CheckIfConstant(Name);
Value = Multiply(Arguments);
break;
}
case "_divide":
case "op/":
case "operator/":
{
Value = _Divide(Arguments);
break;
}
case "op/=":
case "operator/=":
case "divide":
{
CheckIfConstant(Name);
Value = Divide(Arguments);
break;
}
case "_mod":
case "_modulus":
case "op%":
case "operator%":
//.........这里部分代码省略.........
示例14: _Power
/// <summary>
/// Calculate the value of the integer raised to the power of the arguments (doesn't change the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to raise the integer with</param>
/// <returns>The value of the internal integer to the power of the arguments</returns>
public ktValue _Power(ktList Arguments)
{
ktValue Value = ktValue.Null;
int res = m_value;
int a = 1;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't raise an integer with nothing (null)!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Get the argument as an integer
a = GetAsInt((ktValue)L.Node.Value);
// Raise it to the power of the argument
res = (int)Math.Pow((double)res,(double)a);
}
// Create a new ktInt and wrap it in a ktValue
Value = new ktValue("return", "ktInt", new ktInt(res), true, true);
return Value;
}
示例15: _Multiply
/// <summary>
/// Multiply values with the integer (doesn't change the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to multiply with the integer</param>
/// <returns>The product of all the arguments and the internal integer</returns>
public ktValue _Multiply(ktList Arguments)
{
ktValue Value = ktValue.Null;
int res = m_value;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't multiply nothing (null) to an integer!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Multiply with the current argument
res *= GetAsInt((ktValue)L.Node.Value);
}
// Create a new ktInt and wrap it in a ktValue
Value = new ktValue("return", "ktInt", new ktInt(res), true, true);
return Value;
}